Files
fotospiel-app/app/Services/Packages/TenantNotificationPreferences.php
Codex Agent 79b209de9a Limit-Status im Upload-Flow anzeigen (Warnbanner + Sperrzustände).
Upload-Fehlercodes auswerten und freundliche Dialoge zeigen.
2025-11-01 19:50:17 +01:00

43 lines
1.0 KiB
PHP

<?php
namespace App\Services\Packages;
use App\Models\Tenant;
class TenantNotificationPreferences
{
private const DEFAULTS = [
'photo_thresholds' => true,
'photo_limits' => true,
'guest_thresholds' => true,
'guest_limits' => true,
'gallery_warnings' => true,
'gallery_expired' => true,
'event_thresholds' => true,
'event_limits' => true,
'package_expiring' => true,
'package_expired' => true,
'credits_low' => true,
];
public static function defaults(): array
{
return self::DEFAULTS;
}
public function shouldNotify(Tenant $tenant, string $preferenceKey): bool
{
$preferences = $tenant->notification_preferences ?? [];
if (! is_array($preferences)) {
$preferences = [];
}
if (array_key_exists($preferenceKey, $preferences)) {
return (bool) $preferences[$preferenceKey];
}
return self::DEFAULTS[$preferenceKey] ?? true;
}
}