Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Detect and Prevent N+1 Query: With Package or Laravel 8.43+

Premium
2:55

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 14 min)

You also get:

54 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

GA
Ghiath Al-Khatib ✓ Link copied!

hello thank you for this course, I am trying to implement this code "preventLazyLoading" but the query "$user->posts " is executed without the errors. I have written the same code in the article https://laravel-news.com/disable-eloquent-lazy-loading-during-development I can't catch error LazyLoadingViolationException I looked at https://laravel.com/docs/master/eloquent-relationships#lazy-eager-loading and I couldn't prevent lazy loading. Do you have an idea about this laravel v9.19

PK
Povilas Korop ✓ Link copied!

Not sure, I can't "blindly" guess what you did wrong. Maybe your environment is production, that's why preventing doesn't work?

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.