<?php
require_once 'config.php';

checkAccess(['admin', 'programmer']);

$data = json_decode(file_get_contents("php://input"), true);

if (!isset($data['id'])) {
    response(["error" => "ID no proporcionado"], 400);
}

try {
    $stmt = $pdo->prepare("DELETE FROM properties WHERE id = ?");
    $stmt->execute([$data['id']]);
    response(["success" => true]);
} catch (PDOException $e) {
    response(["error" => "No se pudo eliminar: " . $e->getMessage()], 500);
}
?>