Files
ladill-frontdesk/app/Services/Frontdesk/VisitCheckOutService.php
T
isaaccladandCursor 9e2d79936c
Deploy Ladill Frontdesk / deploy (push) Failing after 35s
Test / test (push) Failing after 2m45s
Initial Ladill Frontdesk release with deploy pipeline.
Visitor management app with SSO, kiosk, badges, reports, and Gitea CI deploy to frontdesk.ladill.com.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-27 20:37:15 +00:00

51 lines
1.4 KiB
PHP

<?php
namespace App\Services\Frontdesk;
use App\Models\AuditLog;
use App\Models\Visit;
class VisitCheckOutService
{
public function __construct(
protected NotificationDispatcher $notifications,
protected \App\Services\Integrations\WebhookDispatcher $webhooks,
) {}
public function checkOut(Visit $visit, ?string $actorRef = null): Visit
{
abort_unless($visit->isInside(), 422, 'Visitor is not currently checked in.');
$visit->update([
'status' => Visit::STATUS_CHECKED_OUT,
'checked_out_at' => now(),
'checked_out_by' => $actorRef,
]);
AuditLog::record(
$visit->owner_ref,
'visit.checked_out',
$visit->organization_id,
$actorRef,
Visit::class,
$visit->id,
['visitor' => $visit->visitor->full_name],
);
$this->notifications->visitorCheckedOut($visit);
$this->webhooks->dispatch('visit.checked_out', $visit->fresh(['visitor', 'host']));
return $visit->fresh(['visitor', 'host']);
}
public function checkOutByQrToken(string $ownerRef, string $qrToken, ?string $actorRef = null): Visit
{
$visit = Visit::owned($ownerRef)
->where('qr_token', $qrToken)
->currentlyInside()
->firstOrFail();
return $this->checkOut($visit, $actorRef);
}
}