Laravel Nestedset Versions Save

Effective tree structures in Laravel 4-8

v4.1.0

8 years ago

New features

Converted to trait

Nested set features are now enabled using a trait and overrides as less methods as possible. For smooth transition, Node class is still available but is now deprecated and will be removed in the next significant release. Also, some methods were renamed (see changelog).

Scoping

You can now store multiple trees in the same table by filtering using model attributes. Read more.

Rebuilding a tree

In this release, tree rebuilding feature is added. You can completely rebuild a tree from an array. This can be used when you editing your tree on the client side and then sending full tree to the server. Algorithm updates nodes based on primary key, creates new ones and can delete nodes that are not on array. More info.

Descendants as a relation

Nodes now have descendants relation which can be eagerly loaded. This is helpful when you have a large tree and need to load few subtrees:

$nodes = Category::with('descendants')->whereIn('id', $idList)->get();

Other

hasParent and hasChildren is now deprecated in favor of default laravel functionality has('parent') and has('children').

Default order is no longer applied for siblings(), descendants(), prevNodes(), nextNodes().

Other small features and bug fixes. See changelog.

v4.1.0-beta

8 years ago
  • #75: Converted to trait. Following methods were renamed:
  • appendTo to appendToNode
  • prependTo to prependToNode
  • insertBefore to insertBeforeNode
  • insertAfter to insertAfterNode
  • getNext to getNextNode
  • getPrev to getPrevNode
  • #82: Fixing tree now handles case when nodes pointing to non-existing parent
  • The number of missing parent is now returned when using countErrors
  • #79: implemented scoping feature
  • #81: moving node now makes model dirty before saving it
  • #45: descendants is now a relation that can be eagerly loaded
  • hasChildren and hasParent are now deprecated. Use has('children') has('parent') instead
  • Default order is no longer applied for siblings(), descendants(), prevNodes, nextNodes
  • #50: implemented tree rebuilding feature

v2.0-beta2

9 years ago

v2.0-beta

9 years ago

v1.1

9 years ago