Reputation: 3082
I'm using Laravel's route groups to try and stop duplication within my Routes file.
I have one main group, frontend
. This has the namespace
Frontend
and as
frontend.
Nested within that group, is another group. This group has the prefix
account
which appends /account/
to each route. It also has as
account.
.
The routes inside the nested group, I'd expect to be:
frontend.account.home
frontend.account.order.show
frontend.account.order.index
Instead I get:
frontend.account.home
frontend.account.account.order.index
frontend.account.account.order.show
Code:
Route::group(['as' => 'frontend.', 'namespace' => 'Frontend'], function () {
Route::group(['prefix' => 'account', 'as' => 'account.', 'namespace' => 'Account'], function () {
Route::get('home', [
'as' => 'home',
'uses' => 'Home\Controller@get'
]);
Route::resource('order', 'Order\Controller', ['except' => [
'create',
'store',
'update',
'destroy',
'edit',
]]);
});
});
Upvotes: 0
Views: 1216
Reputation: 562
Since your excepting almost every routes from the Route::resource
method, why not create 2 single routes for index
and show
like so:
// in your routes file, within your nested group :
Route::get('order', ['as' => 'order.index', 'uses' => 'Order\Controller@index' ]);
Route::get('order/{id}', ['as' => 'order.show', 'uses' => 'Order\Controller@show' ]);
Upvotes: 1