perf: 优化saenv、config配置

This commit is contained in:
Ying
2022-09-01 18:38:42 +08:00
parent 3b4eb2c222
commit f6aee95cfc
2 changed files with 14 additions and 7 deletions

View File

@@ -36,11 +36,18 @@ class Config extends Model
*/
public static function all(string $name = '', bool $group = false): array
{
$where = [];
$config = [];
$where = $group ? ['group' => $name] : [];
if (!empty($name) && $group) {
$where[] = ['group', '=', $name];
} else {
if (!empty($name)) {
$where[] = ['name', '=', $name];
}
}
$list = self::where($where)->select()->toArray();
foreach ($list as $option) {
if (!is_empty($option['type']) && 'array' == trim($option['type'])) {
$config[$option['name']] = json_decode($option['value'], true);