From 7d35e923d851fb3952e5db82c7a083629b4842f5 Mon Sep 17 00:00:00 2001 From: Lukas Leitsch Date: Thu, 16 Dec 2021 10:59:31 +0100 Subject: [PATCH 1/2] call relationship directly to allow deletes with lazy loading disabled --- src/CascadeSoftDeletes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CascadeSoftDeletes.php b/src/CascadeSoftDeletes.php index d97d5d0..dffa877 100644 --- a/src/CascadeSoftDeletes.php +++ b/src/CascadeSoftDeletes.php @@ -117,7 +117,7 @@ protected function getCascadingDeletes() protected function getActiveCascadingDeletes() { return array_filter($this->getCascadingDeletes(), function ($relationship) { - return ! is_null($this->{$relationship}); + return ! is_null($this->{$relationship}()); }); } } From dd038abc434db26028430b6b0fed3b5b06299215 Mon Sep 17 00:00:00 2001 From: Lukas Leitsch Date: Mon, 3 Jan 2022 07:32:51 +0100 Subject: [PATCH 2/2] use eloquent exists method --- src/CascadeSoftDeletes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CascadeSoftDeletes.php b/src/CascadeSoftDeletes.php index dffa877..105d380 100644 --- a/src/CascadeSoftDeletes.php +++ b/src/CascadeSoftDeletes.php @@ -117,7 +117,7 @@ protected function getCascadingDeletes() protected function getActiveCascadingDeletes() { return array_filter($this->getCascadingDeletes(), function ($relationship) { - return ! is_null($this->{$relationship}()); + return $this->{$relationship}()->exists(); }); } }