Skip to content

Commit

Permalink
Add model should be strict
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza committed Dec 13, 2024
1 parent 1bca393 commit 326f648
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

return [
'model' => [
'strict' => env('UTILS_MODEL_STRICT', ! app()->environment('production')),
'unguard' => env('UTILS_MODEL_UNGUARD', false),
],

Expand Down
1 change: 1 addition & 0 deletions src/UtilsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private function bootPublishes()
*/
private function bootModel()
{
Model::shouldBeStrict(config('utils.model.strict'));
Model::unguard(config('utils.model.unguard'));
}

Expand Down
2 changes: 2 additions & 0 deletions tests/CustomValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ protected function getEnvironmentSetUp($app): void
{
$app->config->set('utils', [
'model' => [
'strict' => false,
'unguard' => true,
],

Expand All @@ -43,6 +44,7 @@ protected function getEnvironmentSetUp($app): void
public function test_model_unguarded()
{
$this->assertTrue(Model::isUnguarded());
$this->assertFalse(Model::preventsLazyLoading());
}

public function test_locale()
Expand Down
1 change: 1 addition & 0 deletions tests/DefaultValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class DefaultValuesTest extends TestCase
public function test_model_unguarded()
{
$this->assertFalse(Model::isUnguarded());
$this->assertTrue(Model::preventsLazyLoading());
}

public function test_events_locale_updated()
Expand Down

0 comments on commit 326f648

Please sign in to comment.