<?php
namespace Illuminate\Routing;
use Closure;
use Illuminate\Database\Eloquent\ModelNotFoundException;
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);
};
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX