Answer the question
In order to leave comments, you need to log in
How to get username by id in Laravel?
Please advise in this situation.
When creating a post, the id of the user who created this post is also recorded in the database.
How can I specify the author not his id but his name when displaying a list of articles?
Thank you.
Answer the question
In order to leave comments, you need to log in
Post::find($postId)->author->name;
Post::with('author')->find($postId)->author->name;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question