'基础设置', 'license' => '申请协议', 'words' => '自定义文字', 'template_msg' => '模板消息', ]; /** * 更新系统设置 */ public function edit($data) { $this->startTrans(); try { foreach ($data as $key => $values) $this->saveValues($key, $values); $this->commit(); // 删除系统设置缓存 Cache::delete('branch_setting_' . self::$app_id); return true; } catch (\Exception $e) { $this->error = $e->getMessage(); $this->rollback(); return false; } } /** * 保存设置项 */ private function saveValues($key, $values) { $where['key'] = $key; $res = $this->where($where)->select()->count(); $data = [ 'describe' => $this->describe[$key], 'values' => $values, 'app_id' => self::$app_id, ]; if ($res == 1) { return self::update($data, $where); } if ($res == 0) { $data['key'] = $key; return self::create($data); } } }