Anvil
Anvil - The mobile companion for Laravel Forge. Available now. Download for iOS

Enable Strict Mode for Models

  • Laravel
  • Eloquent

If you would like to enable preventLazyLoading, preventAccessingMissingAttributes, and preventSilentlyDiscardingAttributes all at the same time, you can use:

1namespace App\Providers;
2 
3use Illuminate\Database\Eloquent\Model;
4use Illuminate\Support\ServiceProvider;
5 
6class AppServiceProvider extends ServiceProvider
7{
8 public function boot(): void
9 {
10 Model::shouldBeStrict();
11 }
12}