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,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ServiceQueue;
|
||||
use App\Models\Ticket;
|
||||
use App\Services\Qms\QueueEngine;
|
||||
use App\Services\Qms\TicketPresenter;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PublicQueueController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected QueueEngine $engine,
|
||||
) {}
|
||||
|
||||
public function join(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'queue_uuid' => ['required', 'uuid'],
|
||||
'customer_name' => ['nullable', 'string', 'max:255'],
|
||||
'customer_phone' => ['required', 'string', 'max:50'],
|
||||
'customer_email' => ['nullable', 'email'],
|
||||
'priority' => ['nullable', 'string', 'in:'.implode(',', array_keys(config('qms.ticket_priorities')))],
|
||||
]);
|
||||
|
||||
$queue = ServiceQueue::where('uuid', $validated['queue_uuid'])
|
||||
->where('is_active', true)
|
||||
->where('is_paused', false)
|
||||
->firstOrFail();
|
||||
|
||||
$ticket = $this->engine->issueTicket($queue, $queue->owner_ref, [
|
||||
'customer_name' => $validated['customer_name'] ?? null,
|
||||
'customer_phone' => $validated['customer_phone'],
|
||||
'customer_email' => $validated['customer_email'] ?? null,
|
||||
'priority' => $validated['priority'] ?? 'walk_in',
|
||||
'source' => 'mobile',
|
||||
]);
|
||||
|
||||
return response()->json(['data' => TicketPresenter::toArray($ticket)], 201);
|
||||
}
|
||||
|
||||
public function show(string $qrToken): JsonResponse
|
||||
{
|
||||
$ticket = Ticket::where('qr_token', $qrToken)->with(['serviceQueue', 'counter'])->firstOrFail();
|
||||
|
||||
$ahead = Ticket::query()
|
||||
->where('service_queue_id', $ticket->service_queue_id)
|
||||
->where('status', 'waiting')
|
||||
->where('issued_at', '<', $ticket->issued_at)
|
||||
->count();
|
||||
|
||||
$data = TicketPresenter::toArray($ticket, false);
|
||||
$data['customers_ahead'] = $ahead;
|
||||
|
||||
return response()->json(['data' => $data]);
|
||||
}
|
||||
|
||||
public function delay(Request $request, string $qrToken): JsonResponse
|
||||
{
|
||||
$ticket = Ticket::where('qr_token', $qrToken)->whereIn('status', ['waiting', 'on_hold'])->firstOrFail();
|
||||
|
||||
$validated = $request->validate(['minutes' => ['required', 'integer', 'min:5', 'max:120']]);
|
||||
$ticket = $this->engine->delayArrival($ticket, $validated['minutes']);
|
||||
|
||||
return response()->json(['data' => TicketPresenter::toArray($ticket)]);
|
||||
}
|
||||
|
||||
public function cancel(string $qrToken): JsonResponse
|
||||
{
|
||||
$ticket = Ticket::where('qr_token', $qrToken)->whereIn('status', ['waiting', 'on_hold', 'called'])->firstOrFail();
|
||||
$ticket = $this->engine->cancel($ticket);
|
||||
|
||||
return response()->json(['data' => TicketPresenter::toArray($ticket)]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user