I'm trying to get the current route action, but I'm not sure how to go about it. In Laravel 4 I was using Route::currentRouteAction()
but now it's a bit different.
I'm trying to do Route::getActionName()
in my controller but it keeps giving me method not found.
<?php namespace App\Http\Controllers;
use Route;
class HomeController extends Controller
{
public function getIndex()
{
echo 'getIndex';
echo Route::getActionName();
}
}
To get the route action name on Middleware i do that:
EDIT: You will don't get the routes which are protected by this middleware :(
You may use to get the controller details form the request itself
Instead
Use this
If you want to get the alias of the route, you can use:
In Laravel 5.5 if you just want the method/action name i.e. show, edit, custom-method etc... do this
No need to use explode or list to get the actual method to be called. Thanks to Laravel who thought of this.