更新菜单接口

This commit is contained in:
yaooo 2023-09-26 09:57:48 +08:00
parent 9e77cf6415
commit 48a14dd3fd

View File

@ -1364,16 +1364,17 @@ class Auth extends BaseController
public function appMenu()
{
$menuList = Db::name('app_menu')->where('is_show', 1)->where('is_disable', 0)->field(['id', 'pid', 'name', 'icon', 'sort', 'paths'])->order('sort', 'asc')->select()->toArray();
$menuData = [];
foreach($menuList as $n) {
if ($n['pid'] == 0) {
$menuData[$n];
$menuData[] = $n;
}
}
foreach($menuData as $n) {
foreach($menuData as $k=>$v) {
foreach($menuList as $ml) {
if ($n['id'] == $ml['pid']) {
$menuData['children'][] = $ml;
if ($v['id'] == $ml['pid']) {
$menuData[$k]['children'][] = $ml;
}
}
}