public function __construct(RouteCollection $collection) { $this->routes = $collection; foreach ($this->routes->all() as $route) { $name = $route->getName(); if (null !== $name) { $this->namedRoutes[$name] = $route; } } }