Ad
Route Names Inside A Group Prefix Does Not Include The Prefix
I have these routes:
Route::group(['middleware' => ['role:admin'], 'prefix' => 'admin'], function()
{
Route::resource(__('route.events'), 'Auth\RoleAdmin\EventController');
});
Route::group(['middleware' => ['role:user'], 'prefix' => 'user'], function()
{
Route::resource(__('route.events'), 'Auth\RoleUser\EventController');
});
I would expect the name of the resources routes start with admin.
and user.
respectively, but it does not happen.
This is the result of the command php artisan route:list
:
| | GET|HEAD | auth/admin/events | events.index | App\Http\Controllers\Auth\RoleAdmin\[email protected] | web,auth,role
:admin,guest,role:admin|user |
| | POST | auth/admin/events | events.store | App\Http\Controllers\Auth\RoleAdmin\[email protected] | web,auth,role
:admin,guest,role:admin|user |
| | GET|HEAD | auth/admin/events/create | events.create | App\Http\Controllers\Auth\RoleAdmin\[email protected] | web,auth,role
:admin,guest,role:admin|user |
| | DELETE | auth/admin/events/{events} | events.destroy | App\Http\Controllers\Auth\RoleAdmin\[email protected] | web,auth,role
:admin,guest,role:admin|user |
| | GET|HEAD | auth/admin/events/{events} | events.show | App\Http\Controllers\Auth\RoleAdmin\[email protected] | web,auth,role
:admin,guest,role:admin|user |
| | PUT|PATCH | auth/admin/events/{events} | events.update | App\Http\Controllers\Auth\RoleAdmin\[email protected] | web,auth,role
:admin,guest,role:admin|user |
| | GET|HEAD | auth/admin/events/{events}/edit | events.edit | App\Http\Controllers\Auth\RoleAdmin\[email protected] | web,auth,role
:admin,guest,role:admin|user |
As you can see the routes of admin and routes of users have the same names, and the names don't include the prefix.
Ad
Answer
The kerbholz's solution is not working, but it helped me to solve.
Route::prefix('admin')
->middleware('role:admin')
->name('admin.') // <-- I had to add this line in order to work
->group(function() {
Route::resource(__('route.events'), 'Auth\RoleAdmin\EventController');
});
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad