roomTypes = ['all' => '全部'] + collect(RoomType::cases())->mapWithKeys( fn($e) => [$e->value => $e->labels()] )->toArray(); $this->selectChanged(Branch::first()->id,"",""); } public function selectChanged($value,$fieldName, $modelId): void { $branch = $value ? Branch::find($value) : null; $this->selectedBranchId=$branch?->id ?? ''; $this->external_ip = $branch?->external_ip ?? ''; } public function render() { $rooms = Room::where('branch_id', $this->selectedBranchId)->orderBy('name')->get(); $floors = $rooms->pluck('floor')->unique()->sort()->values()->toArray(); return view('livewire.grids.room-grid', [ 'rooms' => $rooms, 'floors' => $floors, ]); } }