Add Frontdesk-style Devices registry for POS hardware.
Deploy Ladill POS / deploy (push) Successful in 42s

Register tills, customer displays, kitchen screens, printers, scanners,
and tablets per branch. Customer displays share the branch display token
and mark online when the public screen polls; stale devices go offline
on a schedule.
This commit is contained in:
isaacclad
2026-07-15 21:49:21 +00:00
parent 46c60259c9
commit c01518b0ee
15 changed files with 877 additions and 3 deletions
+62
View File
@@ -0,0 +1,62 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class PosDevice extends Model
{
public const STATUS_ONLINE = 'online';
public const STATUS_OFFLINE = 'offline';
public const STATUS_MAINTENANCE = 'maintenance';
protected $fillable = [
'owner_ref',
'location_id',
'name',
'type',
'status',
'device_token',
'config',
'last_online_at',
];
protected function casts(): array
{
return [
'config' => 'array',
'last_online_at' => 'datetime',
];
}
public function scopeOwned(Builder $query, string $ownerRef): Builder
{
return $query->where('owner_ref', $ownerRef);
}
public function location(): BelongsTo
{
return $this->belongsTo(PosLocation::class, 'location_id');
}
public function isOnline(int $staleMinutes = 10): bool
{
return $this->status === self::STATUS_ONLINE
&& $this->last_online_at
&& $this->last_online_at->gte(now()->subMinutes($staleMinutes));
}
public function typeLabel(): string
{
return (string) (config('pos.device_types.'.$this->type) ?? $this->type);
}
public function usesToken(): bool
{
return in_array($this->type, config('pos.device_token_types', []), true);
}
}