I am having a problem with the laravel5 resource controller. The POST method is working fine however the delete method is not. as you can see from postman i am passing the DELETE _method to the correct route
In the mean time i am using direct routes which are also working fine.
Route::delete('customisemymeal', ['as'=>'customisemymeal', 'uses'=>'UserMealCustomController@destroy']);
Route::post('customisemymeal', ['as'=>'customisemymeal', 'uses'=>'UserMealCustomController@store']);
I have disabled the CSRF token check until this is sorted out.
Can you please help explain why the same method is different for a resource controller compared to a route::delete
?
routes:list
| DELETE | customisemymeal/{customisemymeal} | customisemymeal.destroy | App\Http\Controllers\UserMealCustomController@destroy |
| DELETE | customisemymeal | customisemymeal | App\Http\Controllers\UserMealCustomController@destroy |
To use the route:
Route::resource('customisemymeal', ['as'=>'customisemymeal', 'uses'=>'UserMealCustomController']);
You must abide to a few rules. To delete something you need to use:
domain.com/customisemymeal/resource_id
From your screenshots you are trying to delete a resource, using a different URI.
domain.com/customisemymeal
That won't work.
Rules are:
Index:
GET -> domain.com/resource
Show:
GET -> domain.com/resource/resource_id
create:
GET -> domain.com/resource/create
edit:
GET -> domain.com/resource/resource_id/edit
update:
PATCH / UPDATE -> domain.com/resource/resource_id
store:
POST -> domain.com/resource
delete:
DELETE -> domain.com/resource/resource_id