🆙 Fix code in somephp files an refactored and deleted deprecated code 🆙

This commit is contained in:
Remco
2026-01-19 17:25:31 +01:00
parent 3238cdb8e7
commit 6736e8fe60
9 changed files with 145 additions and 92 deletions
+21 -4
View File
@@ -15,9 +15,11 @@ class SettingsService
public function __construct()
{
try {
Cache::remember('website_settings', now()->addMinutes(5), fn () => Schema::hasTable('website_settings') ? WebsiteSetting::all()->pluck('value', 'key') : collect());
$this->settings = Cache::get('website_settings');
$this->settings = Cache::remember(
'website_settings',
now()->addMinutes(5),
fn () => Schema::hasTable('website_settings') ? WebsiteSetting::all()->pluck('value', 'key') : collect()
);
} catch (Throwable) {
$this->settings = collect();
}
@@ -25,10 +27,25 @@ class SettingsService
public function getOrDefault(string $settingName, ?string $default = null): string
{
if (! $this->settings instanceof \Illuminate\Support\Collection) {
if (! $this->settings instanceof Collection) {
return (string) $default;
}
return (string) $this->settings->get($settingName, $default);
}
public function refresh(): void
{
Cache::forget('website_settings');
try {
$this->settings = Cache::remember(
'website_settings',
now()->addMinutes(5),
fn () => Schema::hasTable('website_settings') ? WebsiteSetting::all()->pluck('value', 'key') : collect()
);
} catch (Throwable) {
$this->settings = collect();
}
}
}