|
@@ -44,15 +44,17 @@ class Config extends BaseController
|
|
|
}
|
|
}
|
|
|
$params['language_code'] = $params['language_code'] ?? 'zh';
|
|
$params['language_code'] = $params['language_code'] ?? 'zh';
|
|
|
|
|
|
|
|
- $params['val'] = $params['type'] == 'rich_text' ? json_encode($params['val']) : $params['val'];
|
|
|
|
|
-
|
|
|
|
|
if (!empty($id)) {
|
|
if (!empty($id)) {
|
|
|
$exist = ConfigModel::where('id', $id)->find();
|
|
$exist = ConfigModel::where('id', $id)->find();
|
|
|
if (!$exist) {
|
|
if (!$exist) {
|
|
|
return $this->error('配置不存在');
|
|
return $this->error('配置不存在');
|
|
|
}
|
|
}
|
|
|
|
|
+ $params['val'] = $exist['type'] == 'rich_text' ? json_encode($params['val']) : $params['val'];
|
|
|
|
|
+
|
|
|
ConfigModel::where('id', $id)->update($params);
|
|
ConfigModel::where('id', $id)->update($params);
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ $params['val'] = $params['type'] == 'rich_text' ? json_encode($params['val']) : $params['val'];
|
|
|
|
|
+
|
|
|
ConfigModel::create($params);
|
|
ConfigModel::create($params);
|
|
|
}
|
|
}
|
|
|
Db::commit();
|
|
Db::commit();
|