Route.group('public', () => {
Route
.resource('objects', 'api/public/ObjectsController')
.only('store')
.addMember('metrics', ['POST'])
.addMember('actions', ['POST'])
.as('public.objects')
})
.prefix('/api/v1/public')
Route.group('api', () => {
Route
.resource('objects', 'api/ObjectsController')
.except('edit', 'create')
.addMember('metrics')
.addMember('users')
.middleware('auth')
})
.prefix('/api/v1')
it generated two identical name
| Method | URI | Action | Middlewares | Name
|------------|------------------------------|----------------------------------------------|---------------------|------------------
| POST | /api/v1/public/objects | api/public/ObjectsController.store | | objects.store
| POST | /api/v1/objects | api/ObjectsController.store | auth | objects.store
Yup, it is a known issue. Will fix it by prefix the group name since that is unique.
@belozer Prefixing the group name will be a breaking change for others since their route names will change.
I will queue this up for the major release. For now I can suggest to make use of as method of resource as follows.
Route
.resource('objects', 'api/public/ObjectsController')
.only('store')
.addMember('metrics', ['POST'])
.addMember('actions', ['POST'])
.as({
store: 'public.objects.store',
metrics: 'public.objects.metrics',
actions: 'public.objects.actions'
})
Route.group could become an hidden extension to allow an object instead a string like Route.group of Laravel
Route::group([
'middleware' => ['web', 'admin'],
'namespace' => 'App\Http\Controllers\Admin',
'prefix' => 'admin',
'as' => 'admin.',
], function ($router) {
require base_path('routes/admin.php');
});
the option property "as" set the prefix for names inside the group
Removed addMember and addCollection, they are super confusing and doesn't add much value either
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@belozer Prefixing the
group namewill be a breaking change for others since their route names will change.I will queue this up for the major release. For now I can suggest to make use of
asmethod of resource as follows.