Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the name of the current route in Laravel 5.5

Tags:

laravel

routes

I know that in previous versions of Laravel you could fetch the name by calling the getCurrentRoute in the route class, but since 5.5 was released it still remains a mystery on how I can do this?

In previous versions, this is how I did it.

Route::getCurrentRoute()->getPath();
like image 373
Adam Craft Avatar asked Jan 25 '18 17:01

Adam Craft


Video Answer


1 Answers

You can call the currentRouteName on the route class.

Route::currentRouteName();

Don't forget to use the class.

use Illuminate\Support\Facades\Route;
like image 98
Ottawa Avatar answered Sep 30 '22 18:09

Ottawa