Skip to content
Advertisement

How is method call passed from `Routes` to `RoutesCollection`?

I am trying to understand how Laravel gets all fresh application routes at this line:

$this->getFreshApplication()['router']->getRoutes()

When I dump $this->getFreshApplication()['router'] then I find an instance of Illuminate/Routing/Route:

enter image description here

This instance (and its traits) have no method getRoutes. This is a method from Illuminate/Routing/RouteCollection.

Why does the method call getRoutes() on the Route instance endup on RouteCollection? I also checked the magic method __get() from Route but it is not evoked when calling getRoutes().

Advertisement

Answer

I think the correct type you get for $this->getFreshApplication()['router'] is IlluminateRoutingRouter instead of a Illuminate/Routing/Route instance.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement