diff --git a/models/tourModel.js b/models/tourModel.js index b3b335a87d69f400f68cf018516d75a4adfacb70..953de6e3f31cb0717915e94b72d2a9581658ebf9 100644 --- a/models/tourModel.js +++ b/models/tourModel.js @@ -78,7 +78,11 @@ class Tour { // ดึงทัวร์ตาม ID static async getTourById(tourId) { - const query = 'SELECT id, name, description, price, duration, userId FROM tours WHERE id = ?'; + const query = ` + SELECT t.id, t.name, t.description, t.price, t.duration, t.userId, c.name AS company_name + FROM tours t + JOIN company c ON t.company_id = c.id + WHERE t.id = ?`; try { const [results] = await pool.execute(query, [tourId]); diff --git a/views/tour-details.ejs b/views/tour-details.ejs index b9be5904a1800950304185317c52f11fa8d0745a..b115db4435c71f2080c84347ff3b73c5ace79ad7 100644 --- a/views/tour-details.ejs +++ b/views/tour-details.ejs @@ -13,9 +13,11 @@ <section> <h2>รายละเอียดทัวร์</h2> - <p>รายละเอียด: <%= tour.description %></p> - <p>Price: <%= tour.price %> THB</p> - <p>ระยะเวลา: <%= tour.duration %> วัน</p> + <p><strong>ชื่อทัวร์:</strong> <%= tour.name %></p> + <p><strong>คำอธิบาย:</strong> <%= tour.description %></p> + <p><strong>ราคา:</strong> <%= tour.price %></p> + <p><strong>ระยะเวลา:</strong> <%= tour.duration %></p> + <p><strong>บริษัท:</strong> <%= tour.company_name %></p> <a href="/" class="btn-edit">ย้อนกลับ</a> </section>