working with Laravel 5.6 and I am going to delete table record from uploads images table. this is controller
public function deleteOneImage($id)
{
Upload::where('id', $id)
->delete();
return redirect()->back()->with('info', 'Image deleted successfully');
}
and delete link in edit.blade.php
@foreach( $vehicles-> uploads as $upload)
<a class="button is-outlined" href="/myads/{{$upload->id}}/delete" onclick="return confirm('Are you sure to want to delete this record?')" >Delete</a></td>
@endforeach
The name of the route wildcard and action argument only matters whenever you want route-model binding, otherwise you can name the wildcard orange and the action method $apple if you wanted.
Do you know that you are actually reaching the correct Controller action; that the correct route is being matched? Do you have another route that could be matched before your get to the route you are showing us, e.g. Route::get('myads/{something_else}/delete', ...? I ask because the Upload is not the expected resource of a myads endpoint.
Also, what @Snapey mentioned earlier about as GET route for a non-safe action is sage advice, follow it!!!
The problem is Laravel does not know whether myads/123/delete/ should delete a Vehicle or an Upload - how can it know whether 123 means a Vehicle id or and Upload id? So it choses the first route that matches. You should instead organise your routes so that it can uniquely identify the resource your want to show, or edit or delete, e.g.