mercredi 27 juillet 2016

How do I route to a controller action when I'm in a routing closure in Laravel 5.2

If I type domain/something/someaction/10 I will catch this with the following routing rule:

Route::get('/{resource}/someaction/{id}', function($resource,$id){
    //do something
});

Now, inside this closure I want to forward this request to a controller's action. But it could be anything, for instance:

$controller_name = transformThisResource($resource).'Controller';
$controller = new $controller_name;
$controller->someaction($id);

The particular problem I am having is that there are around 30 controllers in this project and 3 tasks performed by 3 actions in each of of them behave exactly the same. With a functionality such as the one described above I would need only 3 rules in my routes file.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2awh7IM
via IFTTT

Aucun commentaire:

Enregistrer un commentaire