Open snk-lab opened 5 years ago
It seems to be able to do this way for now.
$parent = $self->parent()->first();
$children = $parent->defaultOrder()->descendantsOf($self->id);
Model::rebuildSubtree($parent, $children->toTree()->toArray());
$self->delete();
Since the sibling is also deleted when the third argument of rebuildSubtree is set to true, it was deleted separately. I hope there is a better and better way.
is there any better solution to solve this ...
If you delete the middle of the tree, the descendants of that tree will be deleted. How can I link the descendants to the target parent without deleting the descendants? If the target element is deleted after changing to Array, and then rebuildTree is executed, parent_id disappears and the Tree structure is broken. Is there any good way?
I'm not good at English. I'm sorry