In Eloquent hasMany() relationships, you can filter out records that have X amount of children records.
// Author -> hasMany(Book::class)$authors = Author::has('books', '>', 5)->get();
Enjoyed This Tip?
Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.
Recent Courses on Laravel Daily
Laravel Boost: Deeper Practical Dive
8 lessons
32 min
Marketing for Developers in 2026
7 lessons
52 min
Roles and Permissions in Laravel 13
14 lessons
57 min