fixed plugin status

This commit is contained in:
Edward Yang 2022-07-01 18:18:45 +08:00
parent 0a8d86fce8
commit 19a141a9c9
2 changed files with 18 additions and 14 deletions

View File

@ -43,11 +43,7 @@ class SettingRepo
public static function getPluginStatus($pluginCode): bool
{
$status = Setting::query()
->where('type', 'plugin')
->where('space', $pluginCode)
->where('name', 'status')
->value('value');
$status = setting("bk.{$pluginCode}");
return (bool)$status;
}

View File

@ -33,16 +33,24 @@ class ShopServiceProvider extends ServiceProvider
protected function loadSettings()
{
$settings = Setting::all(['name', 'value', 'json'])
->keyBy('name')
->transform(function ($setting) {
if ($setting->json) {
return \json_decode($setting->value, true);
$settings = Setting::all(['type', 'space', 'name', 'value', 'json'])
->groupBy('space');
$result = [];
foreach ($settings as $space => $groupSettings) {
$space = $space ?: 'system';
foreach ($groupSettings as $groupSetting) {
$name = $groupSetting->name;
$value = $groupSetting->value;
if ($groupSetting->json) {
$result[$space][$name] = json_encode($value);
} else {
$result[$space][$name] = $value;
}
return $setting->value;
})
->toArray();
config(['bk' => $settings]);
}
}
config(['bk' => $result]);
}
protected function registerGuard()