diff --git a/app/Http/Controllers/RoomControlController.php b/app/Http/Controllers/RoomControlController.php index d59e037..1af64c6 100644 --- a/app/Http/Controllers/RoomControlController.php +++ b/app/Http/Controllers/RoomControlController.php @@ -70,7 +70,7 @@ class RoomControlController extends Controller */ public function receiveRegister(ReceiveRoomRegisterRequest $request): JsonResponse { - $data = $request->only(['branch_id', 'room_name', 'room_ip', 'email']); // 不記錄密碼 + $data = $request->only(['branch', 'room_name', 'room_ip', 'email']); // 不記錄密碼 Log::info('Token Request Payload:', $data); // 1. 驗證帳密(登入用) @@ -183,7 +183,7 @@ class RoomControlController extends Controller $roomType = strtolower($matches[1]); // 'PC' → 'pc' $roomName = $matches[2]; // '101' } - $room = Room::where('branch_id', $validated['branch_id']) + $room = Room::where('branch', $validated['branch_id']) ->where('name', $roomName) ->where('type', $roomType) ->first(); diff --git a/app/Http/Requests/ReceiveRoomRegisterRequest.php b/app/Http/Requests/ReceiveRoomRegisterRequest.php index d092061..a9af873 100644 --- a/app/Http/Requests/ReceiveRoomRegisterRequest.php +++ b/app/Http/Requests/ReceiveRoomRegisterRequest.php @@ -7,8 +7,8 @@ use Illuminate\Foundation\Http\FormRequest; /** * @OA\Schema( * schema="ReceiveRoomRegisterRequest", - * required={"branch_id", "room_name", "email" ,"password"}, - * @OA\Property(property="branch_id", type="integer", example="1"), + * required={"branch", "room_name", "email" ,"password"}, + * @OA\Property(property="branch", type="string", example="1"), * @OA\Property(property="room_name", type="string", example="PC101"), * @OA\Property(property="room_ip", type="string", example="192.168.1.1"), * @OA\Property(property="email", type="string", example="XX@gmail.com"), @@ -25,7 +25,7 @@ class ReceiveRoomRegisterRequest extends ApiRequest public function rules(): array { return [ - 'branch_id' => 'required|integer|exists:branches,id', + 'branch' => 'required|string', 'room_name' => 'required|string', 'room_ip' => 'required|string', 'email' => 'required|email', diff --git a/app/Http/Requests/ReceiveRoomStatusDataRequest.php b/app/Http/Requests/ReceiveRoomStatusDataRequest.php index f392b8d..a369955 100644 --- a/app/Http/Requests/ReceiveRoomStatusDataRequest.php +++ b/app/Http/Requests/ReceiveRoomStatusDataRequest.php @@ -7,8 +7,8 @@ use Illuminate\Foundation\Http\FormRequest; /** * @OA\Schema( * schema="ReceiveRoomStatusDataRequest", - * required={"branch_id","hostname", "ip", "status"}, - * @OA\Property(property="branch_id", type="integer", example="1"), + * required={"branch","hostname", "ip", "status"}, + * @OA\Property(property="branch", type="string", example="1"), * @OA\Property(property="hostname", type="string", example="PC101"), * @OA\Property(property="ip", type="string", example="192.168.XX.XX"), * @OA\Property(property="cpu", type="numeric", example="0.00"), @@ -26,7 +26,7 @@ class ReceiveRoomStatusDataRequest extends ApiRequest public function rules(): array { return [ - 'branch_id' =>'required|integer|exists:branches,id', + 'branch' =>'required|string', 'hostname' => 'required|string', 'ip' => 'required|string', 'cpu' => 'nullable|numeric', diff --git a/app/Models/MachineStatus.php b/app/Models/MachineStatus.php index fd9f19b..0784c26 100644 --- a/app/Models/MachineStatus.php +++ b/app/Models/MachineStatus.php @@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\Model; * @OA\Schema( * schema="MachineStatus", * type="object", - * @OA\Property(property="branch_name", type="string", example="測試"), + * @OA\Property(property="branch", type="string", example="測試"), * @OA\Property(property="hostname", type="string", example="PC101"), * @OA\Property(property="ip", type="string", example="192.168.XX.XX"), * @OA\Property(property="cpu", type="numeric", example="0.00"), @@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\Model; class MachineStatus extends Model { protected $fillable = [ - 'branch_name', + 'branch', 'hostname', 'ip', 'cpu', diff --git a/database/migrations/2025_05_21_170205_create_machine_statuses_table.php b/database/migrations/2025_05_21_170205_create_machine_statuses_table.php index 8833ab7..e134114 100644 --- a/database/migrations/2025_05_21_170205_create_machine_statuses_table.php +++ b/database/migrations/2025_05_21_170205_create_machine_statuses_table.php @@ -13,7 +13,7 @@ return new class extends Migration { Schema::create('machine_statuses', function (Blueprint $table) { $table->id(); - $table->string('branch_name'); + $table->string('branch'); $table->string('hostname'); $table->string('ip')->nullable(); $table->decimal('cpu', 5, 2)->nullable();