Ketan Akbari
Ketan Akbari

Reputation: 11267

how to use delete method in route in laravel 5.2

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');

Upvotes: 4

Views: 8398

Answers (2)

Deepak Kumar T P
Deepak Kumar T P

Reputation: 1076

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>

Upvotes: 5

Kvlknctk
Kvlknctk

Reputation: 670

Route::resource('/news/{id}', 'NewsController@destroy');

and then select post, put, delete ...

enter image description here

Upvotes: 2

Related Questions