diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index 7fbc524fad8d..13f10370a10d 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -982,29 +982,22 @@ protected function originalIsEquivalent($key, $current) return false; } - if ($current === $original = $this->getOriginal($key)) { - return true; - } + $original = $this->getOriginal($key); - // When check rich this check and current attribute value not equals with original, we should skip next steps - // if current is null - if (is_null($current)) { + if ($current === $original) { + return true; + } elseif (is_null($current)) { return false; + } elseif ($this->isDateAttribute($key)) { + return $this->fromDateTime($current) === + $this->fromDateTime($original); + } elseif ($this->hasCast($key)) { + return $this->castAttribute($key, $current) === + $this->castAttribute($key, $original); } - if ($this->isDateAttribute($key)) { - return $this->fromDateTime($current) === $this->fromDateTime($original); - } - - if ($this->hasCast($key)) { - return $this->castAttribute($key, $current) === $this->castAttribute($key, $original); - } - - // This method checks if the two values are numerically equivalent even if they - // are different types. This is in case the two values are not the same type - // we can do a fair comparison of the two values to know if this is dirty. return is_numeric($current) && is_numeric($original) - && strcmp((string) $current, (string) $original) === 0; + && strcmp((string) $current, (string) $original) === 0; } /**