reset('search', 'room', 'status'); } public function render() { $devices = Device::query() ->with(['room', 'entities.state']) ->when($this->search, fn ($q) => $q->where(fn ($w) => $w ->where('name', 'ilike', "%{$this->search}%") ->orWhere('model', 'ilike', "%{$this->search}%") ->orWhere('vendor', 'ilike', "%{$this->search}%"))) ->when($this->room, fn ($q) => $q->whereHas('room', fn ($r) => $r->where('uuid', $this->room))) ->orderBy('name') ->get(); if ($this->status === 'online') { $devices = $devices->filter->isOnline()->values(); } elseif ($this->status === 'offline') { $devices = $devices->reject->isOnline()->values(); } return view('livewire.devices.index', [ 'groups' => $devices->groupBy(fn ($d) => $d->room?->name ?? __('devices.no_room')), 'total' => $devices->count(), 'rooms' => Room::orderBy('sort')->orderBy('name')->get(), ]); } }