Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use delete method in route in laravel 5.2

Tags:

laravel-5

I want to use delete route in my laravel project.


like and want to send route from href of a anchor tag.
is it possible to use delete method in route from "href" of anchor tag
 Route::delete('/news/{id}', 'NewsController@destroy');
like image 970
Ketan Akbari Avatar asked Mar 13 '23 14:03

Ketan Akbari


1 Answers

You can't use anchor tag with href to send the request to delete. You need a form todo so. With a method DELETE since in form we have only get and post so create a hidden field with name _method and value DELETE Create form similar to this :

<form action="news/id" method="post">
<input type="hidden" name="token" value="{{csrf_token}}" >
<input type="hidden" name="_method" value="DELETE" >
<input type="submit" value="delete " >
</form>
like image 72
Deepak Kumar T P Avatar answered Apr 02 '23 15:04

Deepak Kumar T P