در حال بارگذاری ...

One side-effect to Eloquent's ability to lazy load relationships on the fly is the fact that it occurs behind the scenes. It's not always easy to spot. If you're not thoughtful and careful, this can often lead to the undesirable N+1 problem. Or, in other words, if you fetch one hundred records from the database, you end up with one hundred SQL queries.

Laravel 8 now supports a sort of "strict" mode for lazy loading. When turned on, it disallows it entirely. Instead, an exception will be thrown when your application attempts to lazy load an Eloquent relationship. Let me show you how it works in this Larabit.

Prevent Lazy Loading

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟