Explorar o código

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

whitefang hai 1 ano
pai
achega
2a7c73bec1
Modificáronse 1 ficheiros con 12 adicións e 2 borrados
  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;
+        }
     }
 }