Commentor Name
Closed this issue · 3 comments
maseranw commented
Hi, How can I add commentor name? for non logged in user?
alzaabi98 commented
I have the same request .. I could bring the user_id but it will be great of you can get the name of even eager load the user object along with each comment when run for example $post->comments
frankperez87 commented
Hey @alzaabi98
You can get the user object by calling the relationship of ->commentator
on the comment object.
You can also load in the commenter on all comments using
$comments = $post->comments;
$comments->load('commentator');
timothepearce commented
@frankperez87 You can do that by eager loading the commentator
instead, it will save you one query.
$posts->comments()->with('commentator')->get();