Ali Raza
Ali Raza

Reputation: 83

How to get action name in laravel?

I don't have any idea how to just get action name in Laravel 5.1?? It's giving complete route instead of just action name.

public function saveuserstat(Route $route)
{
    echo $route->getActionName();
}

Upvotes: 3

Views: 2890

Answers (1)

Limon Monte
Limon Monte

Reputation: 54419

As getActionName() returns complete route with controller name and action name, you should do this trick to get action name only:

list(, $action) = explode('@', Route::getCurrentRoute()->getActionName());

Upvotes: 1

Related Questions