Skip to content

Commit

Permalink
do not remove has{One,Many}Through related records
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Oct 14, 2023
1 parent 4ae7171 commit 302ce88
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Database/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 302ce88

Please sign in to comment.