KTVCentral/app/Livewire/Admin/RoomGrid.php
allen.yan 7c8c3fe69b DB 滙入
User 介面 只能看資料不能做修改
Role 介面移除
Branch介面 只能看資料不能做修改
Room 介面 可操控 包廂開關台
Sqgger API 可操控API
Room 有操控異動記錄
machine_statuses 需做資料留存需留7 天
20250528
2025-05-28 09:24:03 +08:00

44 lines
978 B
PHP

<?php
namespace App\Livewire\Admin;
use App\Models\Room;
use App\Models\Branch;
use App\Enums\RoomType;
use Livewire\Component;
use Illuminate\Database\Eloquent\Collection;
class RoomGrid extends Component
{
public $branchName="";
public array $roomTypes;
public function mount()
{
$this->roomTypes = ['all' => '全部'] + collect(RoomType::cases())->mapWithKeys(fn($e) => [$e->value => $e->labels()])->toArray();
}
public function render()
{
$branch = Branch::first();
$this->branchName = $branch->name ?? '';
$rooms = collect(); // 預設為空集合
$floors = [];
if ($branch) {
$rooms = Room::where('branch_id', $branch->id)->get();
$floors = $rooms->pluck('floor')->unique()->sort()->values()->toArray();
}
return view('livewire.admin.room-grid', [
'rooms' => $rooms,
'floors' => $floors,
]);
}
}