Reputation: 2266
My Route Groups names are getting the same prefix twice. Is there something wrong with this code?
$admin_route_group = [
'prefix' => 'admin',
'as' => 'admin.',
'namespace' => 'Admin',
];
Route::group($admin_route_group, function () {
$example_route_group = [
'prefix' => 'example',
'as' => 'example.',
'namespace' => 'Example',
];
Route::group($example_route_group, function () {
Route::resource('something', 'SomethingController', [
'only' => ['index']
]);
});
});
php artisan route:list
output:
admin.example.admin.example.something.index
expected output:
admin.example.something.index
Upvotes: 2
Views: 691
Reputation: 40909
Route names are build using both prefix and as if they are defined. That's the reason why you're getting the same prefix.
The route name is:
{outerGroup.as}.{innerGroup.as}.{outerGroup.prefix}.{innerGroup.prefix}.{resourceName}.{controllerMethod}
Upvotes: 2