I know I can use the with
method to eager load relationships. But how to determine "how many to load"?
For example, a Post
model has many Comment
, I want to load only 5 comments per post. Because a post could have thousands of comments I don't want to load them all. How could I do this?
If I can't do this with Laravel eloquent, what would a raw SQL would be to the same work?
https://stackoverflow.com/questions/66146514/laravel-eloquent-eager-loading-has-many-relationship-with-providing-how-many-t February 11, 2021 at 07:12AM
没有评论:
发表评论