From b648e7ca2bbbe81606e5fa06b455ce021e8685fa Mon Sep 17 00:00:00 2001 From: PGBI Date: Thu, 16 Nov 2017 16:30:40 +0100 Subject: [PATCH 1/2] Model::$exists to be set to false when (force)deleting a model using SoftDeletes --- src/Illuminate/Database/Eloquent/SoftDeletes.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Illuminate/Database/Eloquent/SoftDeletes.php b/src/Illuminate/Database/Eloquent/SoftDeletes.php index ffe8f355197f..d49ea096831e 100644 --- a/src/Illuminate/Database/Eloquent/SoftDeletes.php +++ b/src/Illuminate/Database/Eloquent/SoftDeletes.php @@ -44,6 +44,8 @@ public function forceDelete() */ protected function performDeleteOnModel() { + $this->exists = false; + if ($this->forceDeleting) { return $this->newQueryWithoutScopes()->where($this->getKeyName(), $this->getKey())->forceDelete(); } From d0865e43764359d1675dda37d6ad6175882394ba Mon Sep 17 00:00:00 2001 From: PGBI Date: Thu, 16 Nov 2017 17:05:09 +0100 Subject: [PATCH 2/2] Model::$exists set to false on force deletion only for soft deleteable models --- src/Illuminate/Database/Eloquent/SoftDeletes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Database/Eloquent/SoftDeletes.php b/src/Illuminate/Database/Eloquent/SoftDeletes.php index d49ea096831e..879dad278cd6 100644 --- a/src/Illuminate/Database/Eloquent/SoftDeletes.php +++ b/src/Illuminate/Database/Eloquent/SoftDeletes.php @@ -44,9 +44,9 @@ public function forceDelete() */ protected function performDeleteOnModel() { - $this->exists = false; - if ($this->forceDeleting) { + $this->exists = false; + return $this->newQueryWithoutScopes()->where($this->getKeyName(), $this->getKey())->forceDelete(); }