Skip to content

Chel7ch/nestedSet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel package for working with trees in databases.

Theory: https://webscript.ru/stories/04/09/01/8197045

Using

Each node has 3 unique indexes: id , lk and rk. To start manipulating the nodes of the tree, we learn the attributes of the node:

$prop=array('id'=>5, 'lk'=>3, 'rk'=>8); 

or any part of:

$prop=array('lk'=>3);

$node=(new Node)->prepare($prop);

Select

the entire branch in which our node participates:

$tree = new Categories();
$tree->getEntireBranch($node);

ancestors of node:

$tree->getAncestors($node);

ancestors of the node and node together:

$tree->getAncestorNode($node);

Node's descendants:

$tree->getDescendant($node);

the descendants with a node:

$tree->getDescendantNode($node);

all tree:

$tree->getTree();

Add node

only child node:

$tree->createNode($parantNode, $nodeName);

rename a node:

$tree->renameNode($node, $newName)

delete a node with descendants:

$tree->deleteNode($node);

clear everything:

$tree->cleanTree();

move a node:

$tree->moveNode($node, $newParent);

check the integrity of the tree:

$check= new CheckOfTree(new Categories);
$check->inspect();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages