Level 54
try add this after the form opening tag
...
@csrf
@method('DELETE')
...
Hi.
I have made a gallery images upload and now want to make the delete method, but submitting the delete form redirects me to a 404 page.
web.php
Route::middleware(['auth'])->group(function () {
//[.......]//
Route::delete('series/{series}/gallery_image/{$image}','Series\SeriesController@deleteGalleryImage')->name('series.gallery_image.destroy');
});
route:list
DELETE | series/{series}/gallery_image/{$image} | series.gallery_image.destroy | App\Http\Controllers\Series\SeriesController@deleteGalleryImage | web,auth
blade template
<form method="post" action="{{ route('series.gallery_image.destroy',[$series->id,$photo->id]) }}" onsubmit="return confirm('Really delete?')">
@method('DELETE')
@csrf
<button type="submit" class="btn btn-danger"><i class="feather icon-trash-2"></i></button>
</form>
Form submits to http://localhost/series/2/gallery_image/1 which shows me a 404 page
What am I doing wrong?
you have a $ in your route
Route::delete('series/{series}/gallery_image/{$image}'
^
Please or to participate in this conversation.