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,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Qms;
|
||||
|
||||
use App\Models\QueueAppointment;
|
||||
use App\Models\ServiceQueue;
|
||||
use App\Models\Ticket;
|
||||
|
||||
class AppointmentService
|
||||
{
|
||||
public function __construct(
|
||||
protected QueueEngine $engine,
|
||||
protected QueueNotificationService $notifications,
|
||||
) {}
|
||||
|
||||
public function checkIn(QueueAppointment $appointment, ?string $actorRef = null): Ticket
|
||||
{
|
||||
abort_unless($appointment->status === 'scheduled', 422, 'Appointment cannot be checked in.');
|
||||
|
||||
$queue = $appointment->serviceQueue ?? $this->defaultQueue($appointment);
|
||||
abort_unless($queue, 422, 'No queue configured for this appointment.');
|
||||
|
||||
$ticket = $this->engine->issueTicket($queue, $appointment->owner_ref, [
|
||||
'customer_name' => $appointment->customer_name,
|
||||
'customer_phone' => $appointment->customer_phone,
|
||||
'customer_email' => $appointment->customer_email,
|
||||
'priority' => 'appointment',
|
||||
'source' => 'appointment',
|
||||
'actor_ref' => $actorRef,
|
||||
'metadata' => ['appointment_id' => $appointment->id],
|
||||
]);
|
||||
|
||||
$appointment->update([
|
||||
'status' => 'checked_in',
|
||||
'checked_in_at' => now(),
|
||||
'ticket_id' => $ticket->id,
|
||||
'service_queue_id' => $queue->id,
|
||||
]);
|
||||
|
||||
AuditLogger::record($appointment->owner_ref, 'appointment.checked_in', $appointment->organization_id, $actorRef, QueueAppointment::class, $appointment->id);
|
||||
|
||||
$org = $appointment->organization;
|
||||
if ($org) {
|
||||
app(StaffNotifier::class)->queueEvent(
|
||||
$org,
|
||||
'Appointment checked in',
|
||||
"{$appointment->customer_name} checked in for {$appointment->scheduled_at->format('H:i')}.",
|
||||
route('qms.tickets.show', $ticket),
|
||||
'calendar',
|
||||
);
|
||||
}
|
||||
|
||||
return $ticket;
|
||||
}
|
||||
|
||||
protected function defaultQueue(QueueAppointment $appointment): ?ServiceQueue
|
||||
{
|
||||
return ServiceQueue::owned($appointment->owner_ref)
|
||||
->where('branch_id', $appointment->branch_id)
|
||||
->where('is_active', true)
|
||||
->orderBy('name')
|
||||
->first();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user