binders = Domain::getBindables(); } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle(Request $request, Closure $next) { foreach ($request->route()->parameters() as $key => $value) { if (isset($this->binders[$key])) { $boundObject = $this->performBinding($key, $value, $request->route()); $request->route()->setParameter($key, $boundObject); } } return $next($request); } /** * @param $key * @param $value * @param $route * * @return mixed */ private function performBinding($key, $value, $route) { $class = $this->binders[$key]; return $class::routeBinder($value, $route); } }