php - laravel 使用antisan工具生成的controller的内置方法如何使用
伊谢尔伦
伊谢尔伦 2017-04-10 18:04:57
[PHP讨论组]

1.如何使用这个方法去更新数据,这个方法是使用

php artisan make:controller ArticlesController

生成的

public function update(Request $request, $id)
{
    //
}

在路由中应该如何定义这个方法的访问方式

2.web表单中如何提交delete、put请求,删除只是访问一个链接

/**
 * 资源控制器RESTFUL
 * GET          /articles           ArticlesController@index
 * GET          /articles/create    ArticlesController@create
 * POST         /articles           ArticlesController@store
 * GET          /articles/{id}      ArticlesController@show
 * GET          /articles/{id}/edit ArticlesController@edit
 * PUT/PATCH    /articles/{id}      ArticlesController@update
 * DELETE       /articles/{id}      ArticlesController@destory
 */

表单中如何实现最后的DELTE请求,a发送ajax可以做到使用http的各种请求方式,表单或页面中如何实现

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(1)
天蓬老师

表单中需要加上隐藏列<input type="hidden" name="_method" value="PUT(PATCH、DELETE)">
ps:https://laravel-china.org/top...
ps:https://laravel.com/docs/5.0/...
第一里的删除,是需要DELETE传输方式,要是使用get的话 需要在head里制定传输方式delete,不然没法区别
至于get和delete的区别,你需要去看http的协议!
最下面有个列表!

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号