Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

Commit

Permalink
Change behaviour of updateOrCreate
Browse files Browse the repository at this point in the history
  • Loading branch information
mathcals committed Oct 31, 2018
1 parent 7a07317 commit 1f51c06
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/PersistenceModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,14 @@ protected function deleteByPrimaryKey(array $primary_key_values) {
* Updates the model if it exists,
* otherwise creates it.
* @param PersistentEntity $entity
* @return boolean whether a new row was created
* @return int|false last inserted id if new entity is created, false otherwise
*/
public function updateOrCreate(PersistentEntity $entity) {
if ($this->exists($entity)) {
$this->update($entity);
return true;
} else {
$this->create($entity);
return false;
} else {
return $this->create($entity);
}
}

Expand Down

0 comments on commit 1f51c06

Please sign in to comment.