Files
ladill-frontdesk/app/Console/Commands/EmployeeReturnAlertsCommand.php
isaaccladandCursor 890c2c71e3
Deploy Ladill Frontdesk / deploy (push) Failing after 26s
Add employee presence with kiosk sign-in, QR badges, and mobile step-out.
Enables staff roster, PIN/code kiosk flow, attendance reports, evacuation staff roll call, webhooks, branch mismatch warnings, and a linked-user My presence portal.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 21:11:18 +00:00

38 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\EmployeePresence;
use App\Services\Frontdesk\NotificationDispatcher;
use Illuminate\Console\Command;
class EmployeeReturnAlertsCommand extends Command
{
protected $signature = 'frontdesk:employee-return-alerts';
protected $description = 'Alert staff when employees are overdue returning from step-out';
public function handle(NotificationDispatcher $notifications): int
{
$overdue = EmployeePresence::query()
->where('status', EmployeePresence::STATUS_STEPPED_OUT)
->whereNotNull('expected_return_at')
->where('expected_return_at', '<', now())
->whereNull('return_alert_sent_at')
->with(['employee.organization'])
->get();
$count = 0;
foreach ($overdue as $presence) {
$notifications->employeeOverdueReturn($presence);
$presence->update(['return_alert_sent_at' => now()]);
$count++;
}
$this->info("Sent {$count} overdue return alert(s).");
return self::SUCCESS;
}
}