标题可能有点绕,比如微博首页的消息流,每条消息最多显示5条热门评论,Laravel 关联查询如何实现?
1 | $limit = 5; |
1 | select |
1 | $highestRatedCommentIds = $users->pluck('highest_rated_comment_ids') |
1 | foreach ($users as $user) { |
LIMITing Loaded Relationship Records While Avoiding N+1 in Laravel
标题可能有点绕,比如微博首页的消息流,每条消息最多显示5条热门评论,Laravel 关联查询如何实现?
1 | $limit = 5; |
1 | select |
1 | $highestRatedCommentIds = $users->pluck('highest_rated_comment_ids') |
1 | foreach ($users as $user) { |
LIMITing Loaded Relationship Records While Avoiding N+1 in Laravel