Laravel资源路由

Route::resource('article', 'ArticleController');

如果我们以get的方式请求‘article’,会自动分发到ArticleController的create函数,

post 方式请求‘article’,会跳转到ArticleController的store函数。

其他情况类似,可以参考下面的表格。

 

方法 路径 动作 路由名称
GET /photos index photos.index
GET /photos/create create photos.create
POST /photos store photos.store
GET /photos/{photo} show photos.show
GET /photos/{photo}/edit edit photos.edit
PUT/PATCH /photos/{photo} update photos.update
DELETE /photos/{photo} destroy photos.destroy

 

 

需要注意的是,以 PUT/PATCH/DELETE 请求时,需要在<form>标签内加一行

{{ method_field('PUT') }}

因为html表格不支持PUT/PATCH/DELETE 的请求方法 

posted @ 2019-03-02 15:42  一棍打出屁  阅读(118)  评论(0编辑  收藏  举报