Skip to content

Commit

Permalink
Delete collection tree files when deleting collections
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Dec 11, 2023
1 parent dc83887 commit ecce5a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Entries/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,10 @@ public function delete()
$entry->delete();
});

if ($this->hasStructure()) {
$this->structure()->trees()->each->delete();
}

Facades\Collection::delete($this);

CollectionDeleted::dispatch($this);
Expand Down
2 changes: 1 addition & 1 deletion src/Entries/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ecce5a3

Please sign in to comment.