vendredi 20 mai 2016

Use controller namespace from route closure

I want a Route::group() to use a particular namespace using a closure rather than using the laravel syntax. So instead of

Route::group(['namespace' => 'My\Namespace\For\Controllers'), function () {

     // TestController found in `My\Namespace\For\Controllers`
     Route::resource('resource/url', TestController@test)
}

I wonder if it is possible to have something like

Route::group(function () {

     // Some logic for using the `My\Namespace\For\Controllers` 
     // namespace for all routes within this group

     // Controller found in `My\Namespace\For\Controllers`
     Route::resource('resource/url', Controller@test)
}

I want this functionality so I can decide the controller name-space dynamically depending on a parameter passed to a route.



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

Aucun commentaire:

Enregistrer un commentaire