Open berpcor opened 9 years ago
$categories = [
['id' => 1, 'name' => 'TV & Home Theather'],
['id' => 2, 'name' => 'Tablets & E-Readers'],
['id' => 3, 'name' => 'Computers', 'children' => [
['id' => 4, 'name' => 'Laptops', 'children' => [
['id' => 5, 'name' => 'PC Laptops'],
['id' => 6, 'name' => 'Macbooks (Air/Pro)']
]],
['id' => 7, 'name' => 'Desktops'],
['id' => 8, 'name' => 'Monitors']
]],
['id' => 9, 'name' => 'Cell Phones']
];
Category::buildTree($categories) // => true
And then
$categories = [
['id' => 1, 'name' => 'TV & Home Theather'],
['id' => 2, 'name' => 'Tablets & E-Readers'],
['id' => 3, 'name' => 'Computers', 'children' => [
['id' => 4, 'name' => 'Laptops', 'children' => [
['id' => 6, 'name' => 'Macbooks (Air/Pro)'],
['id' => 5, 'name' => 'PC Laptops'],
]],
['id' => 7, 'name' => 'Desktops'],
['id' => 8, 'name' => 'Monitors']
]],
['id' => 9, 'name' => 'Cell Phones']
];
Category::buildTree($categories) // => true
Changes doesn't make any sense. Nothing changes. Although order should change.
I am using nested sets plugin for generating categories tree. When I pass a new tree to buildTree method everything works fine, but it updates all autoincrement ids in my database. So that I can't use my categories as the ids always changes. Is it normal behavior? What am I to do?