model = new SystemConfig(); } /** * @NodeAnotation(title="列表") */ public function index() { return $this->fetch(); } /** * @NodeAnotation(title="保存") */ public function save() { $this->checkPostRequest(); $post = $this->request->except(['group_name'], 'post'); $group_name = $this->request->post('group_name'); $storage_bytes_keys = ['upload_allow_size']; try { foreach ($post as $key => $val) { if (in_array($key, $storage_bytes_keys)) { $val = parse_bytes($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(); } catch (\Exception $e) { if (FacadeApp::isDebug()) { throw $e; } $this->error('保存失败'); } $this->success('保存成功'); } }