$v) { $temp = []; $temp['path'] = $v['path']; $temp['title'] = $v['title']; $temp['icon'] = $v['icon']; $temp['header'] = $v['code']; $temp['is_header'] = 0; if ($v['is_show_path']) { $temp['auth'] = ['hidden']; } if (!empty($v['children'])) { $temp['children'] = self::toIviewUi($v['children']); } $newData[] = $temp; } return $newData; } /** * 获取树型菜单 * @param $data * @param int $pid * @param int $level * @return array */ public static function getTree($data, $pid = 0, $level = 0) { $childs = self::getChild($data, $pid, $level); array_multisort(array_column($childs, 'seq'), SORT_DESC, $childs); foreach ($childs as $key => $navItem) { $resChild = self::getTree($data, $navItem['id']); if (null != $resChild) { $childs[$key]['children'] = $resChild; } } return $childs; } /** * 获取子菜单 * @param $arr * @param $id * @param $lev * @return array */ private static function getChild(&$arr, $id, $lev) { $child = []; foreach ($arr as $k => $value) { if ($value['pid'] == $id) { $value['level'] = $lev; $child[] = $value; } } return $child; } }