From 1140dfd27d2564f74f796c3ac08e3f54551cd159 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Mon, 10 Apr 2023 11:27:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0=E5=88=86?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/v1/setting/SystemRouteCate.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemRouteCate.php b/crmeb/app/adminapi/controller/v1/setting/SystemRouteCate.php index 86fb7020c..d277d7b99 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemRouteCate.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemRouteCate.php @@ -73,7 +73,7 @@ class SystemRouteCate extends AuthController public function save(Request $request) { $data = $request->postMore([ - ['pid', 0], + ['pid', ''], ['name', ''], ['sort', 0], ['app_name', ''], @@ -84,10 +84,16 @@ class SystemRouteCate extends AuthController } $data['add_time'] = time(); + $pathAttr = explode('/', $data['pid']); + $pathData = []; + foreach ($pathAttr as $item) { + if (!$item) { + $pathData[] = $item; + } + } + $data['pid'] = $pathData[count($pathData) - 1] ?? 0; $res = $this->services->save($data); - - $path = $this->services->getPathValue($data['pid']); - $path = $this->services->setPathValue($path, $res->id); + $path = $this->services->setPathValue($data['pid'], $res->id); $res->path = $path; $res->save();