Left or right of what?
As I understand the package, $parent->appendNode($child) will add $child to $parent. If there are existing children, it will be placed at the bottom.
Also, what do you mean by "fetch [...] based on left position"?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am using the package laravel-nestedset for my multi level marketing(binary) system. However I cannot figure it out how to append the node to specific position.
Let's say for example:
$parent = User::find(1);
$child = User::create(['name' => 'Child', 'username' => 'child1']);
$parent->appendNode($child);
The output will be:
{
id:1,
name: 'Parent',
parent_id: null,
_lft: 1,
_rgt:4,
'username': 'parent1',
'children: [
{
id:2,
name : 'Child',
username: 'child1',
_lft: 2,
_rgt: 3,
parent_id: 1
}
]
}
How do I know if the node is positioned on left or right? And what if I only want to fetch the children of parent based on left position?
Please or to participate in this conversation.