From ecce5a36b566be05b3bed99473ab5729c88f2432 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Mon, 11 Dec 2023 18:34:53 +0000 Subject: [PATCH] Delete collection tree files when deleting collections --- src/Entries/Collection.php | 4 ++++ src/Entries/Entry.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Entries/Collection.php b/src/Entries/Collection.php index 35c7fff87a..3e771844f9 100644 --- a/src/Entries/Collection.php +++ b/src/Entries/Collection.php @@ -732,6 +732,10 @@ public function delete() $entry->delete(); }); + if ($this->hasStructure()) { + $this->structure()->trees()->each->delete(); + } + Facades\Collection::delete($this); CollectionDeleted::dispatch($this); diff --git a/src/Entries/Entry.php b/src/Entries/Entry.php index b57a5b362f..f75ba769fd 100644 --- a/src/Entries/Entry.php +++ b/src/Entries/Entry.php @@ -190,7 +190,7 @@ public function delete() if (optional($parent)->isRoot()) { $parent = null; } - $this->page()->pages()->all()->each(function ($child) use ($tree, $parent) { + $this->page()?->pages()->all()->each(function ($child) use ($tree, $parent) { $tree->move($child->id(), optional($parent)->id()); }); $tree->remove($this);