Download the PHP package artisanweblab/nested-tree without Composer
On this page you can find all versions of the php package artisanweblab/nested-tree. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download artisanweblab/nested-tree
More information about artisanweblab/nested-tree
Files in artisanweblab/nested-tree
Package nested-tree
Short Description Nested Tree package for Laravel
License MIT
Informations about the package nested-tree
Nested Tree for Laravel
The nested set model is an advanced technique for maintaining hierachies among models using parent_id
, nest_left
, nest_right
, and nest_depth
columns. To use a nested set model, apply the ArtisanWebLab\NestedTree\Database\Traits\NestedTreeTrait
trait.
Creating a root node
By default, all nodes are created as roots:
Alternatively, you may find yourself in the need of converting an existing node into a root node:
You may also nullify it's parent_id
column which works the same as `makeRoot'.
Inserting nodes
You can insert new nodes directly by the relation:
Or use the makeChildOf
method for existing nodes:
Deleting nodes
When a node is deleted with the delete
method, all descendants of the node will also be deleted. Note that the delete model events will not be fired for the child models.
Getting the nesting level of a node
The getLevel
method will return current nesting level, or depth, of a node.
Moving nodes around
There are several methods for moving nodes around:
moveLeft()
: Find the left sibling and move to the left of it.moveRight()
: Find the right sibling and move to the right of it.moveBefore($otherNode)
: Move to the node to the left of ...moveAfter($otherNode)
: Move to the node to the right of ...makeChildOf($otherNode)
: Make the node a child of ...makeRoot()
: Make current node a root node.
Copyright (c) 2014-2020 Responsiv Pty Ltd, October CMS