laravel5.4学习(五)-restful

关于RESTful ,下面这篇文章不错。
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');
上面这句话隐含了几个意思:

[table]
|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|
[/table]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值