user3893798
user3893798

Reputation:

Laravel - How to convert the current url to ControllerName@methodName

I could get the current url using {{ URL::current(); }} in Laravel 4.2. But for some reason I need to get the current action, i.e. ControllerName@methodName. Please note that I don't want to generate a url to a controller action. How can I get the current action?

Upvotes: 1

Views: 946

Answers (2)

The Alpha
The Alpha

Reputation: 146269

You may use currentRouteAction() method to get the current route action:

$action = Route::currentRouteAction();

Upvotes: 1

JofryHS
JofryHS

Reputation: 5874

Depends, if you are only trying to get the action name, I think you can use Route method.

Route::currentRouteAction();

You always have access to current Route by calling

$currentRoute = Route::current();

which will probably tell you everything you need to know.

More on Route: http://laravel.com/api/4.2/Illuminate/Routing/Router.html

Upvotes: 2

Related Questions