且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Laravel 5.2中的路由中使用删除方法

更新时间:2023-02-21 09:13:54

您不能使用带有href的定位标记来发送删除请求.您需要执行此操作.使用方法 Delete ,因为在表单中我们只能获取和发布,因此请创建一个名称为_method且值为 DELETE 的隐藏字段. 创建类似于此的表单:

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>