Ajout desactivation check offline machine

This commit is contained in:
bastien
2026-07-09 22:06:27 +02:00
parent 9be2aa3468
commit bac9b0a1e5
4 changed files with 22 additions and 0 deletions
+2
View File
@@ -90,6 +90,8 @@ LAVERIE_BOOKING_PENALTY_AMOUNT=3.00
# Machines # Machines
LAVERIE_MACHINE_OFFLINE_THRESHOLD_MINUTES=10 LAVERIE_MACHINE_OFFLINE_THRESHOLD_MINUTES=10
# Désactiver le passage automatique en hors ligne (démo / dev sans matériel)
LAVERIE_MACHINE_OFFLINE_CHECK_ENABLED=false
# Paiements # Paiements
LAVERIE_PAYMENT_PROVIDER=stripe LAVERIE_PAYMENT_PROVIDER=stripe
@@ -89,6 +89,10 @@ class MachinePageController extends Controller
$validated['qr_code'] = $this->resolveQrCode($validated['qr_code'] ?? null); $validated['qr_code'] = $this->resolveQrCode($validated['qr_code'] ?? null);
$validated['status'] = $validated['status'] ?? 'available'; $validated['status'] = $validated['status'] ?? 'available';
if ($validated['status'] === 'available') {
$validated['last_heartbeat_at'] = now();
}
$machine = Machine::query()->create($validated); $machine = Machine::query()->create($validated);
$this->createSimulatedIntegration($machine); $this->createSimulatedIntegration($machine);
@@ -108,6 +112,14 @@ class MachinePageController extends Controller
unset($validated['qr_code']); unset($validated['qr_code']);
} }
if (
array_key_exists('status', $validated)
&& $validated['status'] === 'available'
&& $machine->status !== 'available'
) {
$validated['last_heartbeat_at'] = now();
}
$machine->update($validated); $machine->update($validated);
return redirect()->route('supervisor.machines.index') return redirect()->route('supervisor.machines.index')
+4
View File
@@ -15,6 +15,10 @@ class RefreshOfflineMachines implements ShouldQueue
public function handle(): void public function handle(): void
{ {
if (! config('laverie.machine.offline_check_enabled', true)) {
return;
}
$thresholdMinutes = (int) config('laverie.machine.offline_threshold_minutes', 10); $thresholdMinutes = (int) config('laverie.machine.offline_threshold_minutes', 10);
$cutoff = now()->subMinutes($thresholdMinutes); $cutoff = now()->subMinutes($thresholdMinutes);
+4
View File
@@ -16,6 +16,10 @@ return [
'machine' => [ 'machine' => [
'offline_threshold_minutes' => (int) env('LAVERIE_MACHINE_OFFLINE_THRESHOLD_MINUTES', 10), 'offline_threshold_minutes' => (int) env('LAVERIE_MACHINE_OFFLINE_THRESHOLD_MINUTES', 10),
'offline_check_enabled' => filter_var(
env('LAVERIE_MACHINE_OFFLINE_CHECK_ENABLED', true),
FILTER_VALIDATE_BOOL
),
], ],
'payment' => [ 'payment' => [