Преглед изворни кода

租户模式配置导致的config配置问题

whitefang пре 1 година
родитељ
комит
2a7c73bec1
1 измењених фајлова са 12 додато и 2 уклоњено
  1. 12 2
      app/common/service/ConfigService.php

+ 12 - 2
app/common/service/ConfigService.php

@@ -110,7 +110,17 @@ class ConfigService
             // 返回本地配置文件中的值
             return config('project.' . $type . '.' . $name);
         }
-        // 返回默认值或本地配置文件中的值
-        return $default_value !== null ? $default_value : config('project.' . $type . '.' . $name);
+
+        // 取某个类型下的所有name的值
+        $data = Config::where(['type' => $type])->column('value', 'name');
+        foreach ($data as $k => $v) {
+            $json = json_decode($v, true);
+            if (json_last_error() === JSON_ERROR_NONE) {
+                $data[$k] = $json;
+            }
+        }
+        if ($data) {
+            return $data;
+        }
     }
 }