This one liner has helped me prevent so many lazy loading issues. I’d even say to step it up a notch and call `Model::shouldBeStrict(!app()->isProduction())` to also catch attributes not being loaded.

I caught so many bugs by doing that, it’s nuts!
Reposted from Renato Hysa
⚡ Stop accidental lazy loading with preventLazyLoading():
Model::preventLazyLoading(!app()->isProduction());

#laravel #ddd #php #softwareengineering #devlob

Comments