laravel-nestedset icon indicating copy to clipboard operation
laravel-nestedset copied to clipboard

Should there be a better api to remove parent/child relationships?

Open izshreyansh opened this issue 4 years ago • 0 comments

If you have set up like this

- Root
-- Child 1
--- Sub child 1

And you just want to remove Sub Child 1 and place it under Root. Or you want to remove all parent child relationship without actually deleting the model. Suggested method is $node->makeRoot()->save(); #169

However this method has its own consequences

The node will be appended to the end of the tree.

Does anyone think there should be better & more elaborate api to remove like so:

$node->parent()->remove();
$node->children()->remove();
$node->ancestors()->remove();
$node->descendants()->remove();

I think that by using this approach we can also solve this issue #205 in a cleaner way.

izshreyansh avatar Apr 13 '20 10:04 izshreyansh