Need Assistance?

support@tutorialshub.in

Eloquent Relationships

Eager Loading (with) & Fixing N+1 Queries

ADVERTISEMENT
Laravel Free Lesson
5 min read
ADVERTISEMENT

If you loop over 50 chapters and access $chapter->language->name inside Blade, Laravel runs 51 separate SQL queries (the N+1 problem). Adding ->with('language') fetches everything in just 2 queries!

ADVERTISEMENT
Hi, I'm Tuby! Here to help you