; localized at runtime (attributes can't call __()). */ public function title(): string { return __('servers.index_title'); } /** A freshly added server should appear without a manual reload (render() re-queries). */ #[On('serverCreated')] public function refreshServers(): void { // } public function render(): View { $term = trim($this->search); $servers = Server::orderBy('name') ->when($term !== '', function ($query) use ($term) { $query->where(function ($q) use ($term) { $q->where('name', 'like', "%{$term}%") ->orWhere('ip', 'like', "%{$term}%"); }); }) ->get(); // Totals reflect the whole fleet, not the filtered result. $counts = Server::query() ->selectRaw('status, count(*) as total') ->groupBy('status') ->pluck('total', 'status'); return view('livewire.servers.index', [ 'servers' => $servers, 'total' => (int) $counts->sum(), 'online' => (int) ($counts['online'] ?? 0), 'warning' => (int) ($counts['warning'] ?? 0), 'offline' => (int) ($counts['offline'] ?? 0), ])->title($this->title()); } }