'基础设置', 'background' => '页面背景图', ]; /** * 更新系统设置 */ public function edit($data) { $this->startTrans(); try { foreach ($data as $key => $values){ $this->saveValues($key, $values); } $this->commit(); // 删除系统设置缓存 Cache::delete('business_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; $where['app_id'] = self::$app_id; $data = [ 'key' => $key, 'describe' => $this->describe[$key], 'values' => $values, 'app_id' => self::$app_id, ]; // 判断是否存在记录,存在则更新,否则新增 $info = self::detail($key); if (empty($info)) { (new self)->save($data); } else { self::update($data, $where); } } }