From 48a14dd3fd63f0c589090e920dff8899362df757 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Tue, 26 Sep 2023 09:57:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=8F=9C=E5=8D=95=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Auth.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index bdb01c8f..347f2485 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -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; } } }