From 1f51c061ec7e77f3ccd05e0cee0fc54fa219cd19 Mon Sep 17 00:00:00 2001 From: Sander Borst Date: Wed, 31 Oct 2018 20:43:10 +0100 Subject: [PATCH] Change behaviour of updateOrCreate --- src/PersistenceModel.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/PersistenceModel.php b/src/PersistenceModel.php index c274d89..09db10b 100644 --- a/src/PersistenceModel.php +++ b/src/PersistenceModel.php @@ -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); } }