Skip to content

Commit

Permalink
refactor: early return
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Dec 7, 2021
1 parent 35b612b commit faa474a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,13 @@ protected function shouldUpdate($data): bool
return false;
}

if ($this->useAutoIncrement === true) {
return true;
}

// When useAutoIncrement feature is disabled, check
// in the database if given record already exists
return $this->useAutoIncrement
? true
: $this->where($this->primaryKey, $this->getIdValue($data))->countAllResults() === 1;
return $this->where($this->primaryKey, $this->getIdValue($data))->countAllResults() === 1;
}

/**
Expand Down

0 comments on commit faa474a

Please sign in to comment.