Laravel Pro Tips
🔥 #Laravel Tip: Eager loading a model’s relationships is a great way to improve performance / avoid the N+1 problem. However, you can go further… with constrained eager loading you can tell Laravel to only load the related records you actually need.
🔥 #Laravel Tip: Protect your database from the dangers of lazy loading by disabling it in your Laravel app. You can also customise how violations are handled, which is perfect for models outside of your control e.g. within packages.
3️⃣ You can enable or disable lazy loading for a model using $preventsLazyLoading
Marian Pop 🇺🇦 Laravel Magazine
No articles were found.