Skip to content

Commit

Permalink
clean up formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Apr 6, 2017
1 parent 558b633 commit e180e20
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit e180e20

Please sign in to comment.