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,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Qms;
|
||||
|
||||
use App\Models\ServiceSession;
|
||||
use App\Models\Ticket;
|
||||
|
||||
class ServiceSessionTracker
|
||||
{
|
||||
public function start(Ticket $ticket, ?string $staffRef = null): ServiceSession
|
||||
{
|
||||
return ServiceSession::create([
|
||||
'owner_ref' => $ticket->owner_ref,
|
||||
'ticket_id' => $ticket->id,
|
||||
'counter_id' => $ticket->counter_id,
|
||||
'staff_ref' => $staffRef,
|
||||
'started_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function endForTicket(Ticket $ticket): ?ServiceSession
|
||||
{
|
||||
$session = ServiceSession::query()
|
||||
->where('ticket_id', $ticket->id)
|
||||
->whereNull('ended_at')
|
||||
->latest('started_at')
|
||||
->first();
|
||||
|
||||
if (! $session) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$ended = now();
|
||||
$session->update([
|
||||
'ended_at' => $ended,
|
||||
'duration_seconds' => $session->started_at->diffInSeconds($ended),
|
||||
]);
|
||||
|
||||
return $session->fresh();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user