|
...
|
...
|
@@ -73,10 +73,39 @@ class NavController extends BaseController |
|
|
|
}
|
|
|
|
$result[] = $items;
|
|
|
|
}
|
|
|
|
foreach ($detailsList as $v){
|
|
|
|
if($v['pid'] == 0){
|
|
|
|
$result[] = $v;
|
|
|
|
}else{//放到对应的上级下面
|
|
|
|
$this->addUnderParent($result,$v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the current item under its parent in the result array
|
|
|
|
*
|
|
|
|
* @param array $result
|
|
|
|
* @param array $item
|
|
|
|
*/
|
|
|
|
private function addUnderParent(&$result, $item) {
|
|
|
|
$parentId = $item['pid'];
|
|
|
|
foreach ($result as &$parent) {
|
|
|
|
if ($parent['id'] == $parentId) {
|
|
|
|
if (!isset($parent['sub'])) {
|
|
|
|
$parent['sub'] = [];
|
|
|
|
}
|
|
|
|
$parent['sub'][] = $item;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!empty($parent['sub'])) {
|
|
|
|
$this->addUnderParent($parent['sub'], $item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取当前id下的所有子集
|
|
|
|
* @name :getSubList
|
|
|
|
* @author :lyh
|
...
|
...
|
|