Skip to content

Commit

Permalink
Eloquent: Call Model::shouldBeStrict() when not in production
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Bates committed Jan 19, 2024
1 parent 8e709e9 commit 1d678f6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Providers;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -21,6 +22,17 @@ public function register(): void
*/
public function boot(): void
{
//
if ($this->isProduction()) {
Model::shouldBeStrict();
}
}

private function isProduction(): bool
{
$environment = $this->app->environment('production');

\assert(\is_bool($environment));

return $environment;
}
}

0 comments on commit 1d678f6

Please sign in to comment.