修复应用设置不生效
parent
a91b72a33e
commit
b39f059c0f
|
|
@ -9,11 +9,6 @@ use Illuminate\Support\Arr;
|
|||
|
||||
class SettingService
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $items = [];
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
|
|
@ -40,19 +35,17 @@ class SettingService
|
|||
|
||||
$_key = $this->getSettingKey($key);
|
||||
|
||||
if (! array_key_exists($_key, $this->items)) {
|
||||
try {
|
||||
$this->items[$_key] = $this->cache->remember($this->cacheKey($_key), $this->ttl, function () use ($_key) {
|
||||
$settings = Setting::where('key', $_key)->firstOrFail();
|
||||
try {
|
||||
$settings[$_key] = $this->cache->remember($this->cacheKey($_key), $this->ttl, function () use ($_key) {
|
||||
$setting = Setting::where('key', $_key)->firstOrFail();
|
||||
|
||||
return $settings->value;
|
||||
});
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return $default;
|
||||
}
|
||||
return $setting->value;
|
||||
});
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return Arr::get($this->items, $key, $default);
|
||||
return Arr::get($settings, $key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,7 +103,6 @@ class SettingService
|
|||
public function cleanCache(string $key): void
|
||||
{
|
||||
$_key = $this->getSettingKey($key);
|
||||
unset($this->items[$_key]);
|
||||
|
||||
$this->cache->forget($this->cacheKey($_key));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue