From 5d292a2b8a250678206e3c4ec5c4920fef2c526b Mon Sep 17 00:00:00 2001 From: Pavel Borunov <8665691+mrneatly@users.noreply.github.com> Date: Sat, 28 May 2022 09:57:03 +0300 Subject: [PATCH] Respect new Laravel accessors's approach Fix getting a value from a one-word `\Illuminate\Database\Eloquent\Casts\Attribute`-returning accessors --- src/Eloquent/Model.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Eloquent/Model.php b/src/Eloquent/Model.php index 226bc357d..ac11b9ae0 100644 --- a/src/Eloquent/Model.php +++ b/src/Eloquent/Model.php @@ -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);