prepare("SELECT value FROM settings WHERE name = ?"); $stmt_shutdown->execute(['emergency_shutdown']); $shutdown_active = ($stmt_shutdown->fetchColumn() === 'true'); $restaurant_id = isset($_GET['restaurant_id']) ? (int)$_GET['restaurant_id'] : 0; if ($restaurant_id === 0) { header('Location: index.php'); exit; } require_once 'header.php'; try { // Fetch restaurant details $stmt = db()->prepare("SELECT r.id, r.name, r.image_url, STRING_AGG(c.name, ', ') as cuisines FROM restaurants r LEFT JOIN restaurant_cuisines rc ON r.id = rc.restaurant_id LEFT JOIN cuisines c ON rc.cuisine_id = c.id WHERE r.id = :id GROUP BY r.id"); $stmt->bindParam(':id', $restaurant_id, PDO::PARAM_INT); $stmt->execute(); $restaurant = $stmt->fetch(PDO::FETCH_ASSOC); if (!$restaurant) { throw new Exception("Restaurant not found."); } // Fetch menu items $menu_stmt = db()->prepare("SELECT id, name, description, price, image_url FROM menu_items WHERE restaurant_id = :restaurant_id ORDER BY name ASC"); $menu_stmt->bindParam(':restaurant_id', $restaurant_id, PDO::PARAM_INT); $menu_stmt->execute(); $menu_items = $menu_stmt->fetchAll(PDO::FETCH_ASSOC); // Fetch ratings and calculate average $ratings_stmt = db()->prepare("SELECT r.rating, r.review, r.created_at, u.name as user_name FROM ratings r JOIN users u ON r.user_id = u.id WHERE r.restaurant_id = :restaurant_id ORDER BY r.created_at DESC"); $ratings_stmt->bindParam(':restaurant_id', $restaurant_id, PDO::PARAM_INT); $ratings_stmt->execute(); $ratings = $ratings_stmt->fetchAll(PDO::FETCH_ASSOC); $average_rating = 0; $rating_count = count($ratings); if ($rating_count > 0) { $total_rating = array_sum(array_column($ratings, 'rating')); $average_rating = round($total_rating / $rating_count, 1); } // Check if this restaurant is a favorite for the current user $is_favorite = false; if (isset($_SESSION['user_id'])) { $fav_stmt = db()->prepare("SELECT COUNT(*) FROM favorite_restaurants WHERE user_id = :user_id AND restaurant_id = :restaurant_id"); $fav_stmt->bindParam(':user_id', $_SESSION['user_id'], PDO::PARAM_INT); $fav_stmt->bindParam(':restaurant_id', $restaurant_id, PDO::PARAM_INT); $fav_stmt->execute(); $is_favorite = $fav_stmt->fetchColumn() > 0; } } catch (Exception $e) { echo "

" . $e->getMessage() . "

"; require_once 'footer.php'; exit; } ?>

( reviews)

Menu


This restaurant has no menu items yet.

Reviews

""


This restaurant has no reviews yet.

Leave a Review

Log in to leave a review.