<?php
require_once '../app/Core/init.php';
Auth::requireAdmin();

header('Content-Type: application/json');

if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_POST['id']) || !isset($_POST['status'])) {
    echo json_encode(['success' => false, 'message' => 'Invalid request']);
    exit;
}

$category_model = new Category();
$result = $category_model->updateStatus((int)$_POST['id'], $_POST['status']);

echo json_encode(['success' => $result]);