Skip to content

Commit a31c474

Browse files
author
Admin
committed
Add bool $returnNullOnInvalidColumnAttributeAccess = true to base model and frozen attributes - refactor change error message - based on this idea: laravel/framework#55188
1 parent 3755815 commit a31c474

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Models/Attributes/BaseModelFrozenAttributes.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ public function __get(string $key): mixed
4646
return $result;
4747
}
4848

49-
/** this will throw if not set */
50-
return $this->mirror->{$key};
49+
try {
50+
return $this->mirror->{$key};
51+
} catch (\Throwable $e) {
52+
throw new \Exception('Undefined attribute: ' . $key . ' in frozen model: ' . static::class);
53+
}
5154
}
5255

5356
/**

0 commit comments

Comments
 (0)