From 602992f7c74857d6a976ea16723cbade64fd547c Mon Sep 17 00:00:00 2001 From: augushong Date: Mon, 20 Dec 2021 09:48:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=85=8D=E7=BD=AE=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=B7=BB=E5=8A=A0;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/system/Config.php | 37 +++++++++++++++++++++----- app/admin/view/system/config/site.html | 2 +- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/admin/controller/system/Config.php b/app/admin/controller/system/Config.php index 1c959b3..60aec4d 100644 --- a/app/admin/controller/system/Config.php +++ b/app/admin/controller/system/Config.php @@ -48,14 +48,38 @@ class Config extends AdminController public function save() { $this->checkPostRequest(); - $post = $this->request->post(); + + $post = $this->request->except(['group_name'], 'post'); + + $group_name = $this->request->post('group_name'); + try { foreach ($post as $key => $val) { - $this->model - ->where('name', $key) - ->update([ - 'value' => $val, + + if (empty($group_name)) { + + $this->model + ->where('name', $key) + ->update([ + 'value' => $val, + ]); + } else { + $model_config = SystemConfig::where('group', $group_name) + ->where('name', $key) + ->find(); + + if (empty($model_config)) { + $model_config = SystemConfig::create([ + 'group' => $group_name, + 'name' => $key, + 'value' => $val + ]); + } + + $model_config->save([ + 'value' => $val ]); + } } TriggerService::updateMenu(); TriggerService::updateSysconfig(); @@ -64,5 +88,4 @@ class Config extends AdminController } $this->success('保存成功'); } - -} \ No newline at end of file +} diff --git a/app/admin/view/system/config/site.html b/app/admin/view/system/config/site.html index 9ad46ba..372e71d 100644 --- a/app/admin/view/system/config/site.html +++ b/app/admin/view/system/config/site.html @@ -1,5 +1,5 @@
- +