etrepat / baum

Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.
http://etrepat.com/baum
MIT License
2.24k stars 460 forks source link

makeFirstChildOfRoot() #225

Open judgej opened 8 years ago

judgej commented 8 years ago

I'm trying to sort siblings into a specified order. Although there is no way to specify exact positions of siblings (would be nice to be able to say, "this is the order - put them like that") I can at least run through siblings in order, placing them as the last child of their shared parent, and that will sort them all out, albeit inefficiently.

This does not work for root nodes. There appears to be no way to make a node the first or last (or ideally the Nth) root node. They can only be shifted around in relation to each other, which makes putting a root node at the start quite cumbersome.

So would it make sense to introduce methods to makeFirstChildOfRoot() or probably more accurately makeFirstRoot() and then makeLastRoot() and possibly makeNthRoot().

Similarly makeNthChildOf() would be very nice, as it supports drag-and-drop positioning of nodes in a GUI very well.