feat(layout): Layout-Einstellungen, Dark-Mode, Logo, Hilfe-Menü
- Settings Key-Value Store (DB + Cache) - Einstellungen → Layout: Seitenname, Logo, Button-Farbe, Dark/Light-Mode - Hilfe-Menü (Ebene 0): Handbuch + Changelog im Browser - Navigation erweitert: Einstellungen-Dropdown + Hilfe-Dropdown - CHANGELOG v0.4.0 Version: 0.4.0
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class SettingsService
|
||||
{
|
||||
private const CACHE_KEY = 'app_settings';
|
||||
private const CACHE_TTL = 3600;
|
||||
|
||||
public function all(): array
|
||||
{
|
||||
return Cache::remember(self::CACHE_KEY, self::CACHE_TTL, fn() => Setting::allAsArray());
|
||||
}
|
||||
|
||||
public function get(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return $this->all()[$key] ?? $default;
|
||||
}
|
||||
|
||||
public function set(string $key, mixed $value): void
|
||||
{
|
||||
Setting::set($key, $value);
|
||||
Cache::forget(self::CACHE_KEY);
|
||||
}
|
||||
|
||||
public function setMany(array $data): void
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
Setting::set($key, $value);
|
||||
}
|
||||
Cache::forget(self::CACHE_KEY);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user