where('device_token', $token) ->first(); } public function recordHeartbeat(Device $device): Device { $device->update([ 'status' => 'online', 'last_online_at' => now(), ]); return $device->fresh(); } public function markStaleDevicesOffline(int $minutes = 10): int { return Device::query() ->where('status', 'online') ->where(function ($q) use ($minutes) { $q->whereNull('last_online_at') ->orWhere('last_online_at', '<', now()->subMinutes($minutes)); }) ->update(['status' => 'offline']); } /** @param array $config */ public function defaultConfigForType(string $type): array { return match ($type) { 'badge_printer' => ['driver' => config('frontdesk.printers.default_driver', 'pdf')], 'kiosk' => ['mode' => 'self_service', 'allow_checkout' => false], default => [], }; } }