Visitor management app with SSO, kiosk, badges, reports, and Gitea CI deploy to frontdesk.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
869 B
PHP
30 lines
869 B
PHP
<?php
|
|
|
|
namespace App\Services\Frontdesk;
|
|
|
|
use App\Models\Organization;
|
|
|
|
class NotificationPreferenceService
|
|
{
|
|
/** @return list<string> */
|
|
public function channelsForEvent(Organization $organization, string $event): array
|
|
{
|
|
if (! $this->isEventEnabled($organization, $event)) {
|
|
return [];
|
|
}
|
|
|
|
return array_values(array_filter(
|
|
$organization->settings['notification_channels'] ?? ['email'],
|
|
fn (string $channel) => in_array($channel, array_keys(config('frontdesk.notification_channels', [])), true),
|
|
));
|
|
}
|
|
|
|
public function isEventEnabled(Organization $organization, string $event): bool
|
|
{
|
|
$events = $organization->settings['notification_events']
|
|
?? config('frontdesk.default_notification_events', []);
|
|
|
|
return (bool) ($events[$event] ?? true);
|
|
}
|
|
}
|