I am just getting started with the CakePHP 3 Tree behaviour (https://book.cakephp.org/3.0/en/orm/behaviors/tree.html). I have a situation where I have an existing tree and I would like to reorder them based on an array. I tried it like this:
$data = [
[
'id' => 1,
'parent_id' => null,
'children' => [
[
'id' => 3,
'children' => [
'id' => 4,
'children' => [
'id' => 5
]
]
]
]
],
[
'id' => 2,
'parent_id' => false
],
];
$minutesTable->patchEntities($minutes, $data);
$minutesTable->saveMany($minutes);
...Hoping that the children field would work, but unfortunately no. The attempt above doesn't return an error, but the children field is simply ignored.
Is there a built-in way to achieve this? What would an elegant alternative be?
Just to add: changing an individual parent_id works in my application. What I am looking for is completely restructuring the tree using a reference array.