jeudi 24 décembre 2015

Laravel model binding not working for delete

I am asking a very basic question, and i searched for more than two hours, but still i was not able to fix it. I am new to laravel, and trying to read their example for Tasks. But some how the delete is not working. Below is my code for route:

Route::delete('/task/{task}', function(\AltafBlog\Task $task) {
     $task->delete();
     return redirect('/');
});

And below is my form for delete:

<form action="{{url('/task', [$task->id])}}" method="post">
   {{csrf_field()}}
   {{method_field('DELETE')}}
   <button class="btn btn-danger">Delete</button>
</form>

Now when i click on delete button, it does not delete the item in the table. Also, i dont get any error message. Adding new items and listing them are working fine. I am not sure what i am doing wrong. Can anybody suggest what is going on there?

Thank you



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire