Courses

Better Eloquent Performance

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

Previous: Eager Loading with load() and $with
avatar

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

avatar

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

avatar
You can use Markdown
avatar
You can use Markdown