PUT|PATCH api/v1/tweets/{tweet}/comments/{comment} tweets.comments.update › Api\\V1\\TweetCommentController@update
我有上面的这个路由,我试图绑定控制器的关系
我正在用键 * comment = This is a test comment
* 传递格式数据
我在TweetCommentController中尝试了下面的代码。
public function update(Tweet $tweet, TweetComment $comment, TweetCommentRequest $request)
但这是行不通的。它只是重定向到登录页面。
我也试过下面这个
public function update(Tweet $tweet, TweetComment $comment)
这一个似乎工作,至少我可以记录$tweet和$comment。,但我不能访问表单数据。
请帮帮忙。
1条答案
按热度按时间nkhmeac61#
我的错误,我尝试了api调用从 Postman ,我用了方法PUT。
我将方法更改为POST并在表单数据中添加一个新键
_method = PUT
因此,我当前的(工作)代码如下所示
API调用
发布{{基本网址}}/推文/1/评论/2
form-data:comment =“已编辑的测试备注”
_方法= PUT
控制器