Warning: This article was written in 2019, the content might be out of date.
Warning: This article was written in 2019, the content might be out of date.
Laravel Resourceful Route Without Prefix
Categories: General
The resource controller contain a method for each of the available resource operations.
For example:
Route::resource('photos', 'PhotoController');
is handle by the verbs in the controller. such as
/photos
/photos/create
/photos/{photo}
/photos/{photo}/edit
...
If you want the resource without the name, you can do
Route::resource('/', 'PhotoController');
but the parameters will not work properly since the route will become
/
/create
/{}
/{}/edit
in order to "fix" that, you can do
Route::resource('/', 'PhotoController')->parameters([
'' => 'photo',
]);
so the route now is
/
/create
/{photo}
/{photo}/edit