Answer the question
In order to leave comments, you need to log in
How to select records that have N records from another eloquent table?
For example, there is a table with people and their purchased cars. How to choose people who have less than 3 purchased cars?
Is it possible to do this in one request?
Answer the question
In order to leave comments, you need to log in
https://laravel.com/docs/8.x/eloquent-relationship...
// Retrieve all posts that have three or more comments...
$posts = Post::has('comments', '>=', 3)->get();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question