I'm using Laravel 5.5 and wonder if I can not only group routes by name prefixes and route prefixes but also controllers since they all use the same controller. The documentation didn't provide anything the like. In Laravel 4 there were implicit controllers available by using Route::controller()
but that's not what I'm looking for since this won't be implicit. To cut a long story short, here's what I currently have:
Route::group([ 'prefix' => 'my-route', 'as' => 'myRoute.' ] , function () {
Route::get('/{viewMode?}', 'MyRouteController@index')->name('index')->where('viewMode', '[a-z]+');
Route::get('/ajax', 'MyRouteController@ajax')->name('ajax');
});
And it should look something like that:
Route::group([ 'prefix' => 'my-route', 'as' => 'myRoute.', 'controller' => 'MyRouteController' ] , function () {
Route::get('/{viewMode?}', 'index')->name('index')->where('viewMode', '[a-z]+');
Route::get('/ajax', 'ajax')->name('ajax');
});
Is there a way to achieve this kind of behavior?
Thanks in advance!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire