reset('search', 'datacenter', 'status'); } public function render() { $hosts = Host::query() ->withCount('instances') // The VPN column reads SyncVpnPeers' synced row, not a live hub // call — the console container has no wg0 (see VpnPeer::vpnPeer() // and SyncVpnPeers' docblock). One eager-loaded query for the // whole page, not one per host. ->with('vpnPeer') ->when($this->search !== '', function ($q) { $term = '%'.$this->search.'%'; $q->where(fn ($w) => $w->where('name', 'like', $term)->orWhere('public_ip', 'like', $term)); }) ->when($this->datacenter !== '', fn ($q) => $q->where('datacenter', $this->datacenter)) ->when($this->status !== '', fn ($q) => $q->where('status', $this->status)) ->orderBy('datacenter')->orderBy('name') ->get(); return view('livewire.admin.hosts', [ 'hosts' => $hosts, 'datacenters' => Datacenter::query()->orderBy('name')->get(), 'statuses' => ['pending', 'onboarding', 'active', 'error', 'disabled'], 'total' => Host::query()->count(), // Für die aufklappbare Anleitung: dieselbe Adresse, die später in // der Befehlszeile steht, damit hier nichts anderes behauptet wird // als dort getan wird. 'archiveUrl' => \App\Support\HostTakeoverCommand::archiveUrl(), ]); } }