- Fix: Notifiable-Trait zum User-Model hinzugefuegt (behebt notify()-500er) - Installer: SMTP-Verbindungstest mit EsmtpTransport + Ueberspringen-Link - Admin: Neuer E-Mail-Tab mit SMTP-Konfiguration + Verbindungstest - Admin: Lazy Quill-Initialisierung (nur sichtbare Locale wird geladen) - Uebersetzungen: 17 neue Mail-Keys in allen 6 Sprachen Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.2 KiB
PHP
Executable File
48 lines
1.2 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 für den gegebenen User sichtbar ist.
|
|
* Admin sieht immer alles.
|
|
*/
|
|
public static function isFeatureVisibleFor(string $feature, User $user): bool
|
|
{
|
|
if ($user->isAdmin()) {
|
|
return true;
|
|
}
|
|
|
|
$key = "visibility_{$feature}_{$user->role->value}";
|
|
|
|
return static::get($key, '1') === '1';
|
|
}
|
|
}
|