Created
May 31, 2023 13:37
-
-
Save mayanksdudakiya/8d38ccd780fcd7dfc8cb3ebb8e315902 to your computer and use it in GitHub Desktop.
Prevent lazy loading in Laravel and check for N+1 queries being fired in your App so that you can solve it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Support\ServiceProvider; | |
class AppServiceProvider extends ServiceProvider | |
{ | |
public function register() | |
{ | |
} | |
public function boot() | |
{ | |
Model::preventLazyLoading(! app()->isProduction()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment