PHP 8.3.31
Preview: RouteBinding.php Size: 3.02 KB
/home/getspomw/royalsquad.us/vendor/laravel/framework/src/Illuminate/Routing/RouteBinding.php

<?php

namespace Illuminate\Routing;

use Closure;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Str;

class RouteBinding
{
    /**
     * Create a Route model binding for a given callback.
     *
     * @param  \Illuminate\Container\Container  $container
     * @param  \Closure|string  $binder
     * @return \Closure
     */
    public static function forCallback($container, $binder)
    {
        if (is_string($binder)) {
            return static::createClassBinding($container, $binder);
        }

        return $binder;
    }

    /**
     * Create a class based binding using the IoC container.
     *
     * @param  \Illuminate\Container\Container  $container
     * @param  string  $binding
     * @return \Closure
     */
    protected static function createClassBinding($container, $binding)
    {
        return function ($value, $route) use ($container, $binding) {
            // If the binding has an @ sign, we will assume it's being used to delimit
            // the class name from the bind method name. This allows for bindings
            // to run multiple bind methods in a single class for convenience.
            [$class, $method] = Str::parseCallback($binding, 'bind');

            $callable = [$container->make($class), $method];

            return $callable($value, $route);
        };
    }

    /**
     * Create a Route model binding for a model.
     *
     * @param  \Illuminate\Container\Container  $container
     * @param  string  $class
     * @param  \Closure|null  $callback
     * @return \Closure
     *
     * @throws \Illuminate\Database\Eloquent\ModelNotFoundException<\Illuminate\Database\Eloquent\Model>
     */
    public static function forModel($container, $class, $callback = null)
    {
        return function ($value, $route = null) use ($container, $class, $callback) {
            if (is_null($value)) {
                return;
            }

            // For model binders, we will attempt to retrieve the models using the first
            // method on the model instance. If we cannot retrieve the models we'll
            // throw a not found exception otherwise we will return the instance.
            $instance = $container->make($class);

            $routeBindingMethod = $route?->allowsTrashedBindings() && in_array(SoftDeletes::class, class_uses_recursive($instance))
                        ? 'resolveSoftDeletableRouteBinding'
                        : 'resolveRouteBinding';

            if ($model = $instance->{$routeBindingMethod}($value)) {
                return $model;
            }

            // If a callback was supplied to the method we will call that to determine
            // what we should do when the model is not found. This just gives these
            // developer a little greater flexibility to decide what will happen.
            if ($callback instanceof Closure) {
                return $callback($value);
            }

            throw (new ModelNotFoundException)->setModel($class);
        };
    }
}

Directory Contents

Dirs: 7 × Files: 38

Name Size Perms Modified Actions
Console DIR
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
Contracts DIR
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
Events DIR
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
Matching DIR
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
8.57 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.34 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
8.82 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.55 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.62 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
2.25 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1009 B lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
2.54 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
524 B lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
4.46 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.05 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
3.10 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
7.56 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
6.83 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.49 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.22 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
7.22 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
3.81 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
21.73 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
8.53 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
32.38 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
3.38 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
3.02 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
6.93 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
2.28 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
135 B lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
641 B lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
2.67 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
3.04 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
39.78 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
8.61 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.60 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.29 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
9.05 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
6.65 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
3.75 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
23.47 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download
1.41 KB lrw-rw-rw- 2025-09-17 06:53:02
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).