实战构架 API 服务器-7.1 发布回复,是如何通过 topic_id 来定位文章的?
public function store(ReplyRequest $request, Topic $topic, Reply $reply) {
$reply->content = $request->contents;
$reply->topic_id = $topic->id;
$reply->user_id = $this->user()->id;
$reply->save();
return $this->response->item($reply, new ReplyTransformer())
->setStatusCode(201);
}
接口地址:
topics/{topic}/replies
推荐文章: