From 302ce88272f72efaaa7c920260926a6c68b339ef Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Sat, 14 Oct 2023 09:21:42 -0400 Subject: [PATCH] do not remove has{One,Many}Through related records --- src/Database/Model.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Database/Model.php b/src/Database/Model.php index c8e77a21..e7c89959 100644 --- a/src/Database/Model.php +++ b/src/Database/Model.php @@ -1018,6 +1018,9 @@ protected function performDeleteOnRelations() if (Arr::get($options, 'detach', true)) { $this->{$name}()->detach(); } + } else if (in_array($type, ['hasOneThrough', 'hasManyThrough'])) { + // the model does not own the relation, we should not remove it. + continue; } else { if (!Arr::get($options, 'delete', false)) { continue;