3
How do I stop at builder of my controller
identify which method was called?
I’m using the Laravel 5.3
and my controller
follows the pattern resource
(index, show, edit
...).
3
How do I stop at builder of my controller
identify which method was called?
I’m using the Laravel 5.3
and my controller
follows the pattern resource
(index, show, edit
...).
2
In the route files, it is configured:
Route::get('/paginas', 'PaginasController@index');
and in the builder utilize:
$controlerAndAction = \Route::currentRouteAction();
exit:
string(44) "App\Http\Controllers\PaginasController@index"
or
$controlerAndAction = \Route::current()->getActionName();
exit:
string(44) "App\Http\Controllers\PaginasController@index"
To catch the action
which in this case is the index
a function like this solves:
$actionName = function ($value)
{
return substr($value, strrpos($value, '@') + 1 );
};
echo $actionName($controlerAndAction);
I didn’t see anything in the documentation directly, until there’s a getAction
but, does not bring direct action (Action
) and often depending on the route configuration (Route
) tail null its value.
Browser other questions tagged laravel laravel-5 laravel-routes
You are not signed in. Login or sign up in order to post.
Just one question? Why do you need this to happen?
– Miguel