<?php
declare(strict_types=1);

require_once __DIR__ . '/../../security/auth_guard.php';
require_once __DIR__ . '/../../config/database.php';
require_once __DIR__ . '/../../core/Response.php';
require_once __DIR__ . '/../../core/Validator.php';

$db = Database::getInstance();
$data = json_decode(file_get_contents('php://input'), true);

Validator::required($data, ['id']);

$stmt = $db->prepare("
    SELECT * FROM hospitality_products WHERE id = :id
");
$stmt->execute(['id' => $data['id']]);

$product = $stmt->fetch();

if (!$product) {
    Response::error('Product not found', 404);
}

Response::success('Product loaded', [
    'product' => $product
]);
