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,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\AuditLog;
|
||||
use App\Models\Visit;
|
||||
use App\Services\Frontdesk\NotificationDispatcher;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class MarkExpiredBadgesCommand extends Command
|
||||
{
|
||||
protected $signature = 'frontdesk:mark-expired-badges';
|
||||
|
||||
protected $description = 'Log and alert on checked-in visits with expired badges';
|
||||
|
||||
public function handle(NotificationDispatcher $notifications): int
|
||||
{
|
||||
$visits = Visit::query()
|
||||
->where('status', Visit::STATUS_CHECKED_IN)
|
||||
->whereNotNull('badge_expires_at')
|
||||
->where('badge_expires_at', '<', now())
|
||||
->with(['visitor', 'organization'])
|
||||
->get();
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ($visits as $visit) {
|
||||
$alreadyLogged = AuditLog::query()
|
||||
->where('subject_type', Visit::class)
|
||||
->where('subject_id', $visit->id)
|
||||
->where('action', 'badge.expired')
|
||||
->where('created_at', '>=', now()->subDay())
|
||||
->exists();
|
||||
|
||||
if ($alreadyLogged) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AuditLog::record(
|
||||
$visit->owner_ref,
|
||||
'badge.expired',
|
||||
$visit->organization_id,
|
||||
null,
|
||||
Visit::class,
|
||||
$visit->id,
|
||||
[
|
||||
'visitor' => $visit->visitor->full_name,
|
||||
'badge_code' => $visit->badge_code,
|
||||
'expired_at' => $visit->badge_expires_at?->toIso8601String(),
|
||||
],
|
||||
);
|
||||
|
||||
$notifications->badgeExpired($visit);
|
||||
$count++;
|
||||
}
|
||||
|
||||
$this->info("Recorded {$count} expired badge alert(s).");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user