Laravel资源路由

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

若是咱们以get的方式请求‘article’,会自动分发到ArticleController的create函数,html

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

其余状况相似,能够参考下面的表格。函数

 

方法 路径 动做 路由名称
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>标签内加一行post

{{ method_field('PUT') }}

由于html表格不支持PUT/PATCH/DELETE 的请求方法 orm

相关文章
相关标签/搜索