I'm working on laravel comment system with vue js, and facing a problem when doing axios request. I need to receive an array as a response with all the comments for the post, but I would like to add user data to this array to get username and rest of users details to display.
public function show($id)
{
$comments = Post::find($id)->comments;
return $comments;
}
Current:
[{"id":35,"user_id":1,"post_id":4,"parent_id":0,"commenttext":"test","created_at":null,"updated_at":null}]
What I would need is:
[{"id":35,"user_id":1,"post_id":4,"parent_id":0,"commenttext":"test","created_at":null,"updated_at":null, "user":[User Data Here]}]