<?php
declare(strict_types=1);
session_start();
require_once '../../config.php';
require_once dirname(__DIR__) . '/helpers.php';
header('Content-Type: application/json');
if (!isset($_SESSION['parent_id'])) { http_response_code(401); echo json_encode([]); exit; }
$conn = portalGetConnection();
if (!$conn instanceof mysqli) { echo json_encode([]); exit; }
echo json_encode(portalGetChildren($conn, (int) $_SESSION['parent_id']));
