1. Home
  2. Laravel
  3. Prevent lazy loading

Add the following code to AppService provider within the boot() method. This is to flag an issue when Laravel is trying to make unnecessary calls to the database. The passed attribute evaluates to a boolean and ensures the debug message doesn't display in the production environment.

#laravel#log#debug
Model::preventLazyLoading( !$this->app->isProduction() );
copy
Full Laravel cheatsheet