Initial Ladill Queue release — enterprise QMS standalone app.
Deploy Ladill Queue / deploy (push) Successful in 56s
Deploy Ladill Queue / deploy (push) Successful in 56s
Phases 1–6: tickets, counters, displays, appointments, workflows, rules, analytics, reports, feedback, admin, device API, and Gitea deploy workflow for queue.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Qms;
|
||||
|
||||
use App\Models\Ticket;
|
||||
use App\Services\Comms\EmailService;
|
||||
use App\Services\Comms\SmsService;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class QueueNotificationService
|
||||
{
|
||||
public function __construct(
|
||||
protected SmsService $sms,
|
||||
protected EmailService $email,
|
||||
) {}
|
||||
|
||||
public function ticketIssued(Ticket $ticket): void
|
||||
{
|
||||
$this->notify($ticket, 'issued', $this->message('issued', $ticket));
|
||||
}
|
||||
|
||||
public function ticketCalled(Ticket $ticket): void
|
||||
{
|
||||
$counter = $ticket->counter?->name ?? 'the counter';
|
||||
$this->notify($ticket, 'called', $this->message('called', $ticket, [':counter' => $counter]));
|
||||
}
|
||||
|
||||
public function customersAhead(Ticket $ticket, int $ahead): void
|
||||
{
|
||||
if ($ahead > 2) {
|
||||
return;
|
||||
}
|
||||
$this->notify($ticket, 'almost_ready', $this->message('almost_ready', $ticket, [':ahead' => (string) $ahead]));
|
||||
}
|
||||
|
||||
public function ticketCompleted(Ticket $ticket): void
|
||||
{
|
||||
$feedbackUrl = route('qms.feedback.show', $ticket->qr_token);
|
||||
$this->notify($ticket, 'completed', $this->message('completed', $ticket, [':feedback_url' => $feedbackUrl]));
|
||||
}
|
||||
|
||||
public function ticketMissed(Ticket $ticket): void
|
||||
{
|
||||
$this->notify($ticket, 'missed', $this->message('missed', $ticket));
|
||||
}
|
||||
|
||||
public function appointmentReminder(\App\Models\QueueAppointment $appointment): void
|
||||
{
|
||||
$message = "Reminder: your appointment at {$appointment->scheduled_at->format('M j, H:i')} is coming up. Ref: {$appointment->reference}";
|
||||
$this->sendToContact($appointment->customer_phone, $appointment->customer_email, $message);
|
||||
}
|
||||
|
||||
protected function notify(Ticket $ticket, string $event, string $message): void
|
||||
{
|
||||
if (! data_get($ticket->serviceQueue?->settings, 'notifications_enabled', true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sendToContact($ticket->customer_phone, $ticket->customer_email, $message);
|
||||
|
||||
Log::info('Queue notification sent', [
|
||||
'event' => $event,
|
||||
'ticket' => $ticket->ticket_number,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function sendToContact(?string $phone, ?string $email, string $message): void
|
||||
{
|
||||
if ($phone) {
|
||||
$this->sms->send($phone, $message);
|
||||
}
|
||||
if ($email) {
|
||||
$this->email->send($email, 'Ladill Queue update', $message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $replace
|
||||
*/
|
||||
protected function message(string $key, Ticket $ticket, array $replace = []): string
|
||||
{
|
||||
$template = config("qms.notification_templates.{$key}", 'Queue update for ticket :ticket.');
|
||||
$replace = array_merge([
|
||||
':ticket' => $ticket->ticket_number,
|
||||
':queue' => $ticket->serviceQueue?->name ?? 'Queue',
|
||||
], $replace);
|
||||
|
||||
return str_replace(array_keys($replace), array_values($replace), $template);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user