http动词用于路由助手功能 [英] http verb for route helper function

查看:609
本文介绍了http动词用于路由助手功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安静的控制器,我想使用销毁功能
这是我的路线:

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|
 +-------------------------------+-----------------------+----------------------+

我正在使用此链接

<a href="{{action('PlayController@destroy', $play->id)}}">Delete</a>

它总是调用 show($ id)功能。所以它使用的是GET动词而不是DELETE。
有没有办法在 route()辅助函数中指定http动词?

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?

推荐答案

您需要创建一个表单来执行该操作。

You need to create a form to do that.

表单需要POST到正确的URI:

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() }}

可以找到有关Laravel表格的信息这里

Information on Laravel forms can be found here

这篇关于http动词用于路由助手功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆