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>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user