From 2c5de5b04d51f35a6638133c036ae62b2abae7ed Mon Sep 17 00:00:00 2001 From: Atiwit Pattanapukdee <65160394@go.buu.ac.th> Date: Thu, 20 Mar 2025 19:02:23 +0700 Subject: [PATCH] Project Round 8 --- controllers/tourController.js | 4 ++-- models/tourModel.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/controllers/tourController.js b/controllers/tourController.js index c4d94bf..612cc94 100644 --- a/controllers/tourController.js +++ b/controllers/tourController.js @@ -213,8 +213,8 @@ exports.postEditTour = async (req, res) => { const tourData = { name, description, price, duration }; try { - await Tour.updateTour(req.params.tourId, tourData); // ตรวจสอบ tourId - res.redirect('/tour/' + req.params.tourId); // ไปที่หน้ารายละเอียดทัวร์ + await Tour.updateTour(req.params.userId, tourData); // ตรวจสอบ tourId + res.redirect('/tour/' + req.params.userId); // ไปที่หน้ารายละเอียดทัวร์ } catch (error) { console.error('Error updating tour:', error); // ข้อผิดพลาด res.status(500).send('เกิดข้อผิดพลาดในการแก้ไขทัวร์'); diff --git a/models/tourModel.js b/models/tourModel.js index 052fd0b..4ec6c34 100644 --- a/models/tourModel.js +++ b/models/tourModel.js @@ -58,7 +58,7 @@ class Tour { // อัปเดตทัวร์ - static async updateTour(tourId, tourData) { + static async updateTour(userId, tourData) { const { name, description, price, duration } = tourData; if (!name || !description || !price || !duration) { @@ -68,7 +68,7 @@ class Tour { const query = 'UPDATE tours SET name = ?, description = ?, price = ?, duration = ? WHERE id = ?'; try { - const [results] = await pool.execute(query, [name, description, price, duration, tourId]); + const [results] = await pool.execute(query, [name, description, price, duration, userId]); console.log('✅ Update results:', results); return results; } catch (error) { -- GitLab