/** * @param $routeName * @param $params * * @return string */ public function __invoke($routeName, array $params = []) { if (false !== strstr($routeName, '@')) { $routeName = explode('@', $routeName); $params['controller'] = $routeName[1]; $routeName = $routeName[0]; } return $this->router->routeNameToUrlString($routeName, $params); }
/** * @param Request $request * @param callable $next * * @return mixed */ public function handle(Request $request, callable $next) { $response = $next($request); if (!$response instanceof Redirect) { return $response; } $url = $this->router->routeNameToUrlString($response->getRouteName(), $response->getParams()); return new RedirectResponse($url, $response->getRedirectionCode()); }