Implement package limit notification system

This commit is contained in:
Codex Agent
2025-11-01 13:19:07 +01:00
parent 81cdee428e
commit 2c14493604
87 changed files with 4557 additions and 290 deletions

View File

@@ -0,0 +1,37 @@
<?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 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;
}
}