devices(); // Group by room in room order; room-less devices go into a trailing "no room" group // so they never disappear from the overview. $groups = []; foreach (Room::orderBy('sort')->orderBy('name')->get() as $room) { $roomDevices = $devices->where('room_id', $room->id)->values(); if ($roomDevices->isNotEmpty()) { $groups[] = ['name' => $room->name, 'devices' => $roomDevices]; } } $unassigned = $devices->whereNull('room_id')->values(); if ($unassigned->isNotEmpty()) { $groups[] = ['name' => __('dashboard.no_room'), 'devices' => $unassigned]; } return view('livewire.dashboard', [ 'groups' => $groups, 'summary' => $home->summary($devices), 'warningCount' => count($home->warnings($devices)), ]); } }