-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.x] Opt-in
Model::preventAccessingMissingAttributes()
option (#44283
) * preventAccessingMissingAttributes concept * Reset missing attribute flag * StyleCI * Always revert Model::preventAccessingMissingAttributes * Only throw on retrieved models * Add model name to missing attribute exception message * formatting * fix oversight * add should be strict method Co-authored-by: Taylor Otwell <[email protected]>
- Loading branch information
1 parent
dfb215e
commit 1f86a99
Showing
4 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/Illuminate/Database/Eloquent/MissingAttributeException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Illuminate\Database\Eloquent; | ||
|
||
use OutOfBoundsException; | ||
|
||
class MissingAttributeException extends OutOfBoundsException | ||
{ | ||
/** | ||
* Create a new missing attribute exception instance. | ||
* | ||
* @param \Illuminate\Database\Eloquent\Model $model | ||
* @param string $key | ||
* @return void | ||
*/ | ||
public function __construct($model, $key) | ||
{ | ||
parent::__construct(sprintf( | ||
'The attribute [%s] either does not exist or was not retrieved for model [%s].', | ||
$key, get_class($model) | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters