JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbrmake($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); }; } }