I am using Laravel with Eloquent with MySQL.
I have three tables POSTS, USERS and COMMENTS. My POST and COMMENT are in one-to-many relation thus with the following code I get the list of Comments for particular POST id
$post = Post::where('id', $id)->get();
$comment = Post::find($id)->comment()->paginate(10);
return view('posts\single', ['post' => $post, 'comments' => $comment]);
Now I want to get the Details of each user from the USER table. I don't want to use the foreach() and then get details of every single ID. Is there any method by which I can get all the Comments (from COMMENTS table) including user details (from USER table) at a single call.
JOIN? w3schools.com/sql/sql_join.asp