From 899e3c16d59f6cf58b29a0911e8e53e076e2fe6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=CC=88nther=20Debrauwer?= Date: Mon, 13 Sep 2021 16:38:34 +0200 Subject: [PATCH] Cast attribute manually --- src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index b57ecec1df9..b125baed4e4 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -1659,10 +1659,12 @@ public function originalIsEquivalent($key) return $this->castAttribute($key, $attribute) === $this->castAttribute($key, $original); } elseif ($this->isClassCastable($key)) { - $original = $this->normalizeCastClassResponse($key, $this->resolveCasterClass($key)->set( + $caster = $this->resolveCasterClass($key); + + $original = $this->normalizeCastClassResponse($key, $caster->set( $this, $key, - $this->castAttribute($key, $original), + $caster instanceof CastsInboundAttributes ? $original : $caster->get($this, $key, $original, $this->attributes), $this->attributes ));