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,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Qms;
|
||||
|
||||
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\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class MobileQueueController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected QueueEngine $engine,
|
||||
) {}
|
||||
|
||||
public function joinForm(): View
|
||||
{
|
||||
return view('qms.mobile.join');
|
||||
}
|
||||
|
||||
public function join(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'queue_uuid' => ['required', 'uuid'],
|
||||
'customer_name' => ['nullable', 'string', 'max:255'],
|
||||
'customer_phone' => ['required', 'string', 'max:50'],
|
||||
]);
|
||||
|
||||
$queue = ServiceQueue::where('uuid', $validated['queue_uuid'])->where('is_active', true)->firstOrFail();
|
||||
|
||||
$ticket = $this->engine->issueTicket($queue, $queue->owner_ref, [
|
||||
'customer_name' => $validated['customer_name'] ?? null,
|
||||
'customer_phone' => $validated['customer_phone'],
|
||||
'source' => 'mobile',
|
||||
]);
|
||||
|
||||
return redirect()->route('qms.mobile.show', $ticket->qr_token);
|
||||
}
|
||||
|
||||
public function show(string $qrToken): View
|
||||
{
|
||||
$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();
|
||||
|
||||
return view('qms.mobile.show', [
|
||||
'ticket' => $ticket,
|
||||
'presented' => TicketPresenter::toArray($ticket, false),
|
||||
'customersAhead' => $ahead,
|
||||
'pollUrl' => route('qms.mobile.data', $qrToken),
|
||||
]);
|
||||
}
|
||||
|
||||
public function data(string $qrToken): \Illuminate\Http\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();
|
||||
|
||||
return response()->json([
|
||||
'data' => TicketPresenter::toArray($ticket, false),
|
||||
'customers_ahead' => $ahead,
|
||||
]);
|
||||
}
|
||||
|
||||
public function delay(Request $request, string $qrToken): RedirectResponse
|
||||
{
|
||||
$ticket = Ticket::where('qr_token', $qrToken)->whereIn('status', ['waiting', 'on_hold'])->firstOrFail();
|
||||
$validated = $request->validate(['minutes' => ['required', 'integer', 'min:5', 'max:120']]);
|
||||
$this->engine->delayArrival($ticket, $validated['minutes']);
|
||||
|
||||
return back()->with('success', 'Arrival delayed.');
|
||||
}
|
||||
|
||||
public function cancel(string $qrToken): RedirectResponse
|
||||
{
|
||||
$ticket = Ticket::where('qr_token', $qrToken)->whereIn('status', ['waiting', 'on_hold', 'called'])->firstOrFail();
|
||||
$this->engine->cancel($ticket);
|
||||
|
||||
return redirect()->route('qms.mobile.join')->with('success', 'Ticket cancelled.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user