Skip to content

Commit 5d292a2

Browse files
authored
Respect new Laravel accessors's approach
Fix getting a value from a one-word `\Illuminate\Database\Eloquent\Casts\Attribute`-returning accessors
1 parent f4c448f commit 5d292a2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: src/Eloquent/Model.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,12 @@ public function getAttribute($key)
155155
}
156156

157157
// This checks for embedded relation support.
158-
if (method_exists($this, $key) && ! method_exists(self::class, $key)) {
159-
return $this->getRelationValue($key);
158+
if (
159+
method_exists($this, $key)
160+
&& ! method_exists(self::class, $key)
161+
&& ! $this->hasAttributeGetMutator($key)
162+
) {
163+
return $this->getRelationValue($key);
160164
}
161165

162166
return parent::getAttribute($key);

0 commit comments

Comments
 (0)