diff --git a/models/tourModel.js b/models/tourModel.js index e19e47e00b50b6724c765e28d945a8408fb29994..cd865a83cb82f56f43ed26647fa1f524c23f6c5c 100644 --- a/models/tourModel.js +++ b/models/tourModel.js @@ -29,14 +29,12 @@ class Tour { } // สร้างทัวร์ - static async createTour(tourData) { - const { name, description, price, duration } = tourData; - + static async createTour(name, description, price, duration) { // ตรวจสอบข้อมูล if (!name || !price || !duration) { throw new Error('ข้อมูลไม่ครบถ้วน กรุณากรอกข้อมูลให้ครบถ้วน'); } - + const query = 'INSERT INTO tours (name, description, price, duration) VALUES (?, ?, ?, ?)'; try { await pool.execute(query, [name, description, price, duration]); @@ -45,6 +43,7 @@ class Tour { throw new Error('เกิดข้อผิดพลาดในการสร้างทัวร์'); } } + // อัปเดตทัวร์ static async updateTour(id, tourData) { @@ -74,7 +73,7 @@ class Tour { throw new Error('เกิดข้อผิดพลาดในการลบทัวร์'); } } - } +} class User { static async findOne(email) {