This commit is contained in:
weiz 2024-01-25 14:15:39 +08:00
parent 65deae342a
commit 8120b0c8cc
2 changed files with 2 additions and 2 deletions

View File

@ -60,7 +60,7 @@ class MaterialClassifyLists extends BaseAdminDataLists implements ListsSearchInt
->order(['id' => 'asc'])
->select()
->toArray();
$data[] = ['id'=>0,'pid'=>0,'name'=>'顶级分类'];
$data[] = ['id'=>0,'pid'=>-1,'name'=>'顶级分类'];
return buildTree($data,'pid');
}

View File

@ -307,7 +307,7 @@ function group_by($array, $key): array
return $result;
}
function buildTree($items, $parentField, $parentId = 0): array
function buildTree($items, $parentField, $parentId = -1): array
{
$tree = [];
foreach ($items as $item) {