<?php

namespace App\Http\Controllers;

use App\Models\Agent;
use Illuminate\View\View;

class AgentController extends Controller
{
    public function __invoke(): View
    {
        return view('agents.index', [
            'agents' => Agent::query()->with('website')->orderByDesc('last_heartbeat_at')->paginate(15),
            'stats' => [
                'online' => Agent::query()->where('status', 'online')->count(),
                'offline' => Agent::query()->where('status', 'offline')->count(),
                'verified' => Agent::query()->where('authentication_status', 'verified')->count(),
                'stale' => Agent::query()->where('sync_status', 'stale')->count(),
            ],
        ]);
    }
}
