Skip to content

Commit

Permalink
fix: 修复系统配置对复选框支持不友好的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Jun 25, 2023
1 parent 112f22a commit db6a335
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/Setting/Mapper/SettingConfigMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,23 @@ public function getConfigByKey(string $key): array
*/
public function updateConfig(string $key, array $data): bool
{
return $this->model::query()->where('key', $key)->update($data) > 0;
if (is_array($data['config_select_data'])) {
$data['config_select_data'] = json_encode($data['config_select_data'], JSON_UNESCAPED_UNICODE);
}
return $this->model::query()->where('key', $key)->update($data) > -1;
}

/**
* 按 keys 更新配置
* @param string $key
* @param string|int|bool $value
* @param mixed $value
* @return bool
*/
public function updateByKey(string $key, string|int|bool|null $value = null): bool
public function updateByKey(string $key, mixed $value = null): bool
{
return $this->model::query()->where('key', $key)->update(['value' => $value]) > 0;
return $this->model::query()->where('key', $key)->update([
'value' => is_array($value) ? json_encode($value, JSON_UNESCAPED_UNICODE) : $value
]) > 0;
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/Setting/Request/SettingConfigRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function commonRules(): array
'group_id' => 'required',
'key' => 'required|max:32',
'name' => 'required|max:255',
'value' => '',
'input_type' => '',
'config_select_data' => '',
'sort' => '',
Expand Down

0 comments on commit db6a335

Please sign in to comment.