In this post, i will tell you how can you get your current route name, route path and route action name in Laravel 5 and also you can get all registered route paths in Laravel.
Let's assume, i have created a resource route with productCRUD
and navigating its index method then what will be response if i will use following methods to get information about routes.
- return \Request::route()->getName(); // response productCRUD.index
- return \Route::currentRouteName(); // response productCRUD.index
- return \Route::getCurrentRoute()->getPath(); // response productCRUD
- return \Route::getCurrentRoute()->getActionName(); //response App\Http\Controllers\ProductCRUDController@index
- $routes = \Route::getRoutes();
- foreach ($routes as $route) {
- echo $route->getPath().'<br>';
- }