<?php
declare(strict_types=1);

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

$db = Database::getInstance();

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

if (empty($data['id'])) {
    Response::error('Category id required', 422);
}

$stmt = $db->prepare("
    UPDATE retail_categories
    SET status = 'InActive', updated_at = NOW()
    WHERE id = :id
");
$stmt->execute(['id' => (int)$data['id']]);

Response::success('Retail category deactivated');
