Skip to content

Commit 3755815

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 4586dd2 commit 3755815

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Models/BaseModel.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,11 @@ public function getAttributeValue($key): mixed
366366

367367
/** @see static::transformModelValue() */
368368
if (!$this->hasGetMutator($key) && !$this->hasAttributeGetMutator($key)) {
369-
/** this will throw Exception */
370-
return $this->attributes[$key];
369+
try {
370+
return $this->attributes[$key];
371+
} catch (\Throwable $e) {
372+
throw new \Exception('Undefined attribute: ' . $key . ' in model: ' . static::class);
373+
}
371374
}
372375

373376
return null;

0 commit comments

Comments
 (0)