问题
I have a restful controller and I want to use the destroy function this is my route :
+-------------------------------+-----------------------+----------------------+
|URI |Name |Action |
+-------------------------------+-----------------------+----------------------+
|GET|HEAD playwright/play/{play}|playwright.play.show |PlayController@show |
+-------------------------------+-----------------------+----------------------+
|DELETE playwright/play/{play} |playwright.play.destroy|PlayController@destroy|
+-------------------------------+-----------------------+----------------------+
I'm using this link
<a href="{{action('PlayController@destroy', $play->id)}}">Delete</a>
And it is always calling the show($id)
function. So the it is using the GET verb instead of DELETE.
Is there a way to specify the http verb in the route()
helper function?
回答1:
You need to create a form to do that.
The form needs to POST to the right URI:
{{ Form::open(array('url' => URL::route('playwright.play.destroy'), 'method' => 'DELETE')) }}
{{ Form::submit('Delete me!')}}
{{ Form::close() }}
Information on Laravel forms can be found here
来源:https://stackoverflow.com/questions/23063966/http-verb-for-route-helper-function