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,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Frontdesk;
|
||||
|
||||
use App\Models\Device;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DeviceService
|
||||
{
|
||||
public function generateToken(): string
|
||||
{
|
||||
return Str::random(48);
|
||||
}
|
||||
|
||||
public function findByToken(string $token): ?Device
|
||||
{
|
||||
return Device::query()
|
||||
->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<string, mixed> $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 => [],
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user