reset('search', 'datacenter', 'status'); } public function render() { $hosts = Host::query() ->withCount('instances') ->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(), ]); } }