Skip to content

Commit

Permalink
Respect new Laravel accessors's approach
Browse files Browse the repository at this point in the history
Fix getting a value from a one-word `\Illuminate\Database\Eloquent\Casts\Attribute`-returning accessors
  • Loading branch information
mrneatly authored May 28, 2022
1 parent f4c448f commit 5d292a2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,12 @@ public function getAttribute($key)
}

// This checks for embedded relation support.
if (method_exists($this, $key) && ! method_exists(self::class, $key)) {
return $this->getRelationValue($key);
if (
method_exists($this, $key)
&& ! method_exists(self::class, $key)
&& ! $this->hasAttributeGetMutator($key)
) {
return $this->getRelationValue($key);
}

return parent::getAttribute($key);
Expand Down

0 comments on commit 5d292a2

Please sign in to comment.