veilig
veilig

Reputation: 5135

laravel 4 get controller method from route

if I have a simple route

Route::get('foo', 'path\to\controller\MyController@bar');

when I'm in my application - Is there a method/function that will return the controller method that was used? ie: bar

.... is there anything like \Route::getCurrentControllerMethod()

Upvotes: 2

Views: 1449

Answers (2)

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111829

In case you only want get bar from your current Route, you should use:

$method = explode('@', Route::currentRouteAction());
$method = end ($method);

Upvotes: 3

George G
George G

Reputation: 7695

Try one of these:

Route::getCurrentRoute()->getAction();
Route::currentRouteAction();
Route::currentRouteName();

http://forumsarchive.laravel.io/viewtopic.php?id=10095

Upvotes: 1

Related Questions