diff --git a/controllers/tourController.js b/controllers/tourController.js index c4d94bf991613979a58ff1e586c0ea3104857cf3..612cc9414d7709bb248b2919db67c52af9bf7011 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 052fd0b0d6855e03e0ea37cea0f208cf1dbc13fc..4ec6c34265d677f944ff1037b10b0794a9eb4890 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) {