$client->isConfigured(), 'baseUrl' => $client->configuredUrl(), 'assets' => [ 'total' => SnipeAsset::query()->count(), 'active' => SnipeAsset::query()->where('active', true)->count(), 'requestable' => SnipeAsset::query() ->where('active', true) ->where('requestable', true) ->count(), ], 'syncRuns' => SyncRun::query() ->latest('started_at') ->limit(10) ->get() ->map(fn (SyncRun $run): array => [ 'id' => $run->id, 'status' => $run->status->value, 'started_at' => $run->started_at->toIso8601String(), 'finished_at' => $run->finished_at?->toIso8601String(), 'records_processed' => $run->records_processed, 'records_created' => $run->records_created, 'records_updated' => $run->records_updated, 'records_disabled' => $run->records_disabled, 'error_message' => $run->error_message, ]), ]); } public function testConnection(SnipeItClient $client): RedirectResponse { $startedAt = hrtime(true); try { $page = $client->listHardwarePage(0, 1); $duration = (int) round((hrtime(true) - $startedAt) / 1_000_000); return back()->with('success', "Ligação confirmada em {$duration} ms. O Snipe-IT reporta {$page->total} equipamentos."); } catch (Throwable $exception) { report($exception); return back()->with('error', $exception->getMessage()); } } public function sync(): RedirectResponse { SyncSnipeAssets::dispatch(); return back()->with('success', 'A sincronização de equipamentos foi colocada na fila.'); } }