'$refresh' public bool $showModal = false; public int $branch_id = 0; public $branchName=""; public array $roomTypes; public function mount() { $this->roomTypes = ['all' => '全部'] + collect(RoomType::cases())->mapWithKeys(fn($e) => [$e->value => $e->labels()])->toArray(); } public function openModal($branch_id = null) { $this->branch_id = $branch_id; $branch = Branch::find($branch_id); $this->branchName = Branch::find($branch_id)?->name ?? ''; $this->showModal = true; } public function closeModal(){ $this->showModal = false; $this->branch_id = 0; } public function render() { $rooms = Room::where('branch_id', $this->branch_id)->orderBy('name', 'asc')->get(); // 取得樓層 $floors = $rooms->pluck('floor')->unique()->sort()->values()->toArray(); return view('livewire.admin.room-grid',['rooms' =>$rooms,'floors' =>$floors]); } }