Implement package limit notification system
This commit is contained in:
37
app/Services/Packages/TenantNotificationPreferences.php
Normal file
37
app/Services/Packages/TenantNotificationPreferences.php
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user