Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
AnourValar committed May 20, 2023
1 parent 3681127 commit 85519b5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/ModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ public function setAttribute($key, $value)
return parent::setAttribute($key, $value);
}

/**
* @see \Illuminate\Database\Eloquent\Model
*
* @param string $key
* @return mixed
* @throws \Illuminate\Database\Eloquent\MissingAttributeException
*/
public function getAttribute($key)
{
if (
! \App::isProduction()
&& $this->exists
&& ! $this->wasRecentlyCreated
&& array_key_exists($key, $this->casts)
&& ! array_key_exists($key, $this->attributes)
) {
throw new \Illuminate\Database\Eloquent\MissingAttributeException($this, $key);
}

return parent::getAttribute($key);
}

/**
* @see \Illuminate\Database\Eloquent\Concerns\HasAttributes::asJson()
*
Expand Down

0 comments on commit 85519b5

Please sign in to comment.