From af178bdb718e10fcf5eb7168c97238c8d470613d Mon Sep 17 00:00:00 2001 From: Atiwit Pattanapukdee <65160394@go.buu.ac.th> Date: Thu, 20 Mar 2025 22:51:15 +0700 Subject: [PATCH] Project Round 9 --- models/tourModel.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/models/tourModel.js b/models/tourModel.js index 20924e3..48d2a36 100644 --- a/models/tourModel.js +++ b/models/tourModel.js @@ -102,7 +102,12 @@ class Tour { // ลบทัวร์ static async deleteTour(id) { try { - // ตรวจสอบก่อนว่ามีทัวร์อยู่หรือไม่ + console.log("Deleting tour with ID:", id); // เช็คค่า ID ที่รับมา + if (!id) { + throw new Error("Tour ID is required"); + } + + // ตรวจสอบว่าทัวร์มีอยู่จริง const checkQuery = 'SELECT * FROM tours WHERE id = ?'; const [tours] = await pool.execute(checkQuery, [id]); @@ -125,6 +130,7 @@ class Tour { throw new Error('เกิดข้อผิดพลาดในการลบทัวร์'); } } + } class User { -- GitLab