diff --git a/controllers/tourController.js b/controllers/tourController.js index 35f9447432fc1521baef83ed060527dce3a850ca..92c31d05a87e7a7c18d7783767368b9dd122b5e4 100644 --- a/controllers/tourController.js +++ b/controllers/tourController.js @@ -89,16 +89,16 @@ exports.getCreateTour = (req, res) => { // บันทึกทัวร์ใหม่ exports.createTour = async (req, res) => { try { - const { name, location, price, description } = req.body; + const { name, description, price, duration } = req.body; // ตรวจสอบว่าข้อมูลถูกต้อง - if (!name || !location || !price || !description) { + if (!name || !description || !price || !duration) { return res.status(400).send('กรุณากรอกข้อมูลให้ครบทุกช่อง'); } await pool.query( 'INSERT INTO tours (name, location, price, description) VALUES (?, ?, ?, ?)', - [name, location, price, description] + [name, description, price, duration] ); res.redirect('/'); } catch (error) { @@ -133,7 +133,7 @@ exports.postCreateTour = async (req, res) => { }; exports.postEditTour = async (req, res) => { - + console.log('📥 Data received:', req.body); const { name, description, price, duration } = req.body; const tourData = { name, description, price, duration };