<?php
require_once __DIR__ . '/classes/Subcategory.php';

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

$response = [];

if (isset($_GET['category_id'])) {
    $category_id = $_GET['category_id'];
    $subcategory = new Subcategory();
    $subcategories = $subcategory->getSubcategoriesByCategoryId($category_id);
    $response = $subcategories;
} else {
    $response = ['error' => 'No category ID provided'];
}

echo json_encode($response);
?>