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.

Model::preventLazyLoading( !$this->app->isProduction() );
Full Laravel cheatsheet