需要返回与api资源的关系

时间:2019-05-15 10:49:36

标签: php laravel api eloquent

我有儿童关系,我需要它返回答复,我知道它是空的,但我需要它

public function store(Category $category, Path $path,$level,Task $task,Request $request)
{
    \Auth::loginUsingId(1);

    $this->validate($request ,[
        'body' =>'required|max:5000',
    ]);

    $comment = $task->comments()->make([
        'body' => $request->body
    ]);

    $request->user()->comments()->save($comment);

    return new CommentResource($comment);
}

0 个答案:

没有答案