Ad
Laravel Resource Routes Naming Prefix
I've tow resource routes defined.
Route::resource('p/contacts', 'BaseData\PrivateContactsController');
Route::resource('b/contacts', 'BaseData\ContactController');
My Problem is that both resource group becomes the prefix same prefix (contacts.show
, contacts.edit
...)
In the Laravel docs I found this way to name the routes
Route::resource('photos', 'PhotoController')->names([
'create' => 'photos.build'
]);
In my eyes this way is very complicated becaus I have to set the prefix for each single route. Is there a better way to set the prefix for all routes of the group?
Ad
Answer
Route::resource('p/contacts', 'BaseData\PrivateContactsController',["as"=>"private"]);
Route::resource('b/contacts', 'BaseData\ContactController',["as"=>"normal"]);
this way the urls will stay the same, but the names will have a prefix, for the first resource controller
private.contacts.index or private.contacts.edit
and for the second controller
normal.contacts.create or normal.contacts.show
for more info check the documentation or this github issue
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 create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad