Answer the question
In order to leave comments, you need to log in
Is it correct to define routes this way?
Good afternoon.
Please tell me about routing.
If we define a route group
Route::group($groupData, function () {
//BookCategory
$methods = ['index', 'edit', 'update', 'create', 'store', 'destroy'];
Route::resource('categories', 'CategoryController')
->only($methods)
->names('breh.admin.lib.categories');
Route::resource('books','BookController')
->only($methods)
->names('breh.admin.lib.book');
});
Route::get('/admin/categories/{id}/delete', '[email protected]')
->middleware('is_admin')
->name('breh.admin.lib.categories.delete');
Answer the question
In order to leave comments, you need to log in
Why set it separately if you use Route::resource which supports all this inside of itself?
Implement within the resource.
And where is your delete method here?
The /delete postfix is not needed, because the method will be different, GET /admin/categories/{id} and DELETE /admin/categories/{id} are different routes and without additional divisions.
here is the delete method
This is so incorrect that it is necessary to chop off hands for this. Maximum POST.
PS The question has been asked and answered a million times on the Internet, I suggest that you first acquire the skills of Google, and only then Laravel.
$methods = ['index', 'edit', 'update', 'create', 'store', 'destroy'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question