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 public static function getPluginStatus($pluginCode): bool
{ {
$status = Setting::query() $status = setting("bk.{$pluginCode}");
->where('type', 'plugin')
->where('space', $pluginCode)
->where('name', 'status')
->value('value');
return (bool)$status; return (bool)$status;
} }

View File

@ -33,16 +33,24 @@ class ShopServiceProvider extends ServiceProvider
protected function loadSettings() protected function loadSettings()
{ {
$settings = Setting::all(['name', 'value', 'json']) $settings = Setting::all(['type', 'space', 'name', 'value', 'json'])
->keyBy('name') ->groupBy('space');
->transform(function ($setting) {
if ($setting->json) { $result = [];
return \json_decode($setting->value, true); 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' => $result]);
config(['bk' => $settings]);
} }
protected function registerGuard() protected function registerGuard()