http://www.cnblogs.com/artech/p/3506553.html
先执行帮助命令
php artisan make:controller ArticleController --resource
这时,发现在controller目录下多了一个文件,且里面有几个固定方法。
也可以自动创建目录和命名空间,只需
php artisan make:controller Dir\ArticleController --resource
接下来,可以为该控制器注册一个资源路由:
在routes \ web.php里加上
Route::resource('article', 'ArticleController');
上面这句话隐含了几个意思:
HTTP方法 | URL路径 | 类.方法名称 |
GET | /articles | articles.index |
GET | /articles/create | articles.create |
POST | /articles | articles.store |
GET | /articles/{id} | articles.show |
GET | /articles/{id}/edit | articles.edit |
PUT/PATCH | /articles/{id} | articles.update |
DELETE | /articles/{id} | articles.destroy |