did you ever find a solution to this?
makeNthChildOf() method is missing on etrepat/baum laravel package
I am using etrepat/baum laravel package along with jstree jQuery plugin to manage categories.
In jstree there is a move_node.jstree method used to move nodes. it has useful properties to get info about move action like parent , old _parent, ... and a position that returns new position of moved child node in parent node.
In the other hand there is methods to move nodes too.(here). but there is not any method like makeNthChildOf() that can use to place a child node at specific position of a parent node. like:
$node->makeNthChildOf(newPosition , $parent)
Now in the client to move nodes I wrote this:
$treeview.on('move_node.jstree', function (e, data) {
$.post('/move', {
'CategoryID': data.node.id,
'newParent': data.parent,
'oldParent': data.old_parent
}, function (res) {
data.instance.open_node(data.parent);
}, 'json');
});
And in the laravel :
public function move (Request $request)
{
$data = $request->only('newParent', 'oldParent', 'CategoryID');
$currentNode = Category::find($data['CategoryID']);
if ($data['newParent'] == '#') {
$currentNode->makeRoot();
} else {
$currentNode->makeChildOf($data['newParent']);
}
return ['success' => true];
}
But above code can not do that I want and just can to move a node from a parent to another parent.
I want to know is there any alternate approach to doing that functionality ?
Please or to participate in this conversation.