Home > Backend Development > PHP Tutorial > laravel5 resource路由疑问,最基础的问题

laravel5 resource路由疑问,最基础的问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:23:33
Original
1158 people have browsed it

<code>Route::resource('admin/category', 'Admin\CategoryController');</code>
Copy after login
Copy after login

就定义了上面一个路由,现在我想删除数据,怎么进入destroy方法

回复内容:

<code>Route::resource('admin/category', 'Admin\CategoryController');</code>
Copy after login
Copy after login

就定义了上面一个路由,现在我想删除数据,怎么进入destroy方法

通过更改你的Request的HTTP Method来实现,

GET 就是请求数据
POST 就是添加数据
PUT 是更新数据
DELETE 是删除数据

浏览器访问的话,默认都是GET,表单提交通常都是POST。你要测试你的删除API,可以考虑使用一些REST API的测试工具,各种浏览器都有类似的插件。

由资源控制器处理的行为
动词 路径 行为 路由名称
GET /photo 索引 photo.index
GET /photo/create 创建 photo.create
POST /photo 保存 photo.store
GET /photo/{photo} 显示 photo.show
GET /photo/{photo}/edit 编辑 photo.edit
PUT/PATCH /photo/{photo} 更新 photo.update
DELETE /photo/{photo} 删除 photo.destroy

同时form中要增加一个隐藏域,name="_method"

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template