@lindsey.homenick
To handle a delete request in Laravel, follow these steps:
1
|
Route::delete('/delete/{id}', 'YourController@delete')->name('delete'); |
1 2 3 4 5 6 7 |
public function delete($id) { YourModel::destroy($id); // Optionally, you can redirect or return a response return redirect()->route('your.route.name'); } |
1 2 3 4 5 |
<form action="{{ route('delete', $yourModel->id) }}" method="POST"> @csrf @method('DELETE') <button type="submit">Delete</button> </form> |
Make sure to specify the correct method (DELETE) and the route name when creating the form.