John Davidson

php - Laravel CRUD - Delete - Not route found

0 comments
Message:


Error:



Route [events.destroy] not defined. (View: C:\xampp\htdocs\Event-Manager-Project\resources\views\events\admin.blade.php)



In my view, admin i have this about the delete:


<form action="{{ route('events.destroy', $event->id) }}" method="POST">
<a href="/admin/edit/{{$event->id}}" class="far fa-edit"></a>
@csrf
@method('DELETE')
<button type="submit" class="far fa-trash-alt" ></button>
</form>

In controller this:


public function destroy($id)
{
$event = Event::find($id);
$event->delete();
return redirect('/admin');
}

And using a route resource:


Route::resource('admin', 'App\Http\Controllers\EventController');


My Answer:

@csrf
@method('DELETE')

Rate this post

4 of 5 based on 7809 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us