- Administration & Rollenmanagement: Neuer Admin-Bereich mit Feature-Toggles und Sichtbarkeitseinstellungen pro Rolle (11 Toggles, 24 Visibility-Settings) - AdministrationController mit eigenem Settings-Tab, aus SettingsController extrahiert - Feature-Toggle-Guards in Controllers (Invitation, File, ListGenerator, Comment) und Views (events/show, events/edit, events/create) - Setting::isFeatureEnabled() und isFeatureVisibleFor() Hilfsmethoden - Wiederkehrende Trainings: Täglich/Wöchentlich/2-Wöchentlich mit Ende per Datum oder Anzahl (max. 52), Vorschau im Formular - Event-Serien: Verknüpfung über event_series_id (UUID), Modal-Dialog beim Speichern und Löschen mit Optionen "nur dieses" / "alle folgenden" - Löschen-Button direkt in der Event-Bearbeitung mit Serien-Dialog - DemoDataSeeder: 4 Trainings als Serie mit gemeinsamer event_series_id - Übersetzungen in allen 6 Sprachen (de, en, pl, ru, ar, tr) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
61 lines
1.6 KiB
PHP
Executable File
61 lines
1.6 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class Setting extends Model
|
|
{
|
|
protected $fillable = ['label', 'type', 'value'];
|
|
|
|
public static function get(string $key, ?string $default = null): ?string
|
|
{
|
|
return Cache::remember("setting.{$key}", 3600, function () use ($key, $default) {
|
|
return static::where('key', $key)->value('value') ?? $default;
|
|
});
|
|
}
|
|
|
|
public static function set(string $key, ?string $value): void
|
|
{
|
|
static::where('key', $key)->update(['value' => $value]);
|
|
Cache::forget("setting.{$key}");
|
|
}
|
|
|
|
public static function clearCache(): void
|
|
{
|
|
$keys = static::pluck('key');
|
|
foreach ($keys as $key) {
|
|
Cache::forget("setting.{$key}");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Prüft ob ein Feature global aktiviert ist (Master-Schalter).
|
|
*/
|
|
public static function isFeatureEnabled(string $feature): bool
|
|
{
|
|
return static::get("feature_{$feature}", '1') === '1';
|
|
}
|
|
|
|
/**
|
|
* Prüft ob ein Feature für den gegebenen User sichtbar ist.
|
|
* Prüft zuerst den globalen Schalter, dann die Rollen-Sichtbarkeit.
|
|
* Admin sieht alles, solange das Feature global aktiviert ist.
|
|
*/
|
|
public static function isFeatureVisibleFor(string $feature, User $user): bool
|
|
{
|
|
if (!static::isFeatureEnabled($feature)) {
|
|
return false;
|
|
}
|
|
|
|
if ($user->isAdmin()) {
|
|
return true;
|
|
}
|
|
|
|
$key = "visibility_{$feature}_{$user->role->value}";
|
|
|
|
return static::get($key, '1') === '1';
|
|
}
|
|
}
|