How to get the name of the non-current route in laravel?

2

I have a problem in to get the name of the route not current. Looking in the documentation I found this function currentRouteName() however this works only for the route that is running at that moment.

    
asked by Rony 01.07.2016 в 05:22
source

1 answer

1

Although the question is not very clear, I think that all the possible routes are what you want. To do this you can use the Route::getRoutes() function that returns a list with all the routes.

$routeCollection = Route::getRoutes();

Now you have them all in routeCollection and if you want to iterate through them:

foreach ($routeCollection as $value) {
    echo $value->getPath();
}

So the whole code would be:

$routeCollection = Route::getRoutes();
foreach ($routeCollection as $value) {
    echo $value->getPath();
}
    
answered by 01.07.2016 в 11:25