How to get current route name path and action in laravel 5

How to get current route name path and action in laravel 5

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.

How to get current route name in Laravel

  1. return \Request::route()->getName(); // response productCRUD.index
  2. return \Route::currentRouteName(); // response productCRUD.index
How to get current route path in Laravel

  1. return \Route::getCurrentRoute()->getPath(); // response productCRUD
How to get current route action in Laravel

  1. return \Route::getCurrentRoute()->getActionName(); //response App\Http\Controllers\ProductCRUDController@index
How to get a list of all routes in Laravel?

  1. $routes = \Route::getRoutes();
  2. foreach ($routes as $route) {
  3. echo $route->getPath().'<br>';
  4. }

Phone: (+91) 8800417876
Noida, 201301
sakarya escort sakarya escort sakarya escort sakarya escort serdivan escort izmir escort eporner
akyazı escort sakarya escort ferizli escort sakarya escort geyve escort sakarya escort hendek escort sakarya escort karasu escort sakarya escort sapanca escort serdivan escort webmaster forum
pendik escort atasehir escort