id(); $table->foreignId('branch_id')->constrained()->onDelete('cascade')->comment('關聯分店'); $table->unsignedTinyInteger('floor')->default(1)->comment('樓層'); // 可根據實際狀況決定預設值 $table->enum('type',['unset', 'pc','svr'])->default('unset')->comment('包廂類別'); $table->string('name')->comment('包廂名稱'); $table->string('internal_ip')->nullable()->comment('內部 IP'); $table->unsignedSmallInteger('port')->nullable()->comment('通訊 Port'); $table->tinyInteger('is_online')->default(0)->comment('連線狀態'); $table->enum('status', ['active', 'closed','fire', 'error'])->default('error')->comment('狀態'); // :啟用中 / 已結束 $table->dateTime('started_at')->nullable()->comment('開始時間'); // $table->dateTime('ended_at')->nullable()->comment('結束時間'); // $table->timestamps(); // 👇 複合唯一鍵(分店 + 樓層 + 類型 + 包廂名稱) $table->unique(['branch_id', 'floor', 'type', 'name'], 'unique_room_name_per_branch_floor_type'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('rooms'); } };