<?php
declare(strict_types=1);

header('Content-Type: application/json; charset=utf-8');

$app = app();
$pdo = $app->pdo();

if (!$pdo) {
    http_response_code(500);
    echo json_encode(['error' => 'DB disabled or unavailable'], JSON_UNESCAPED_UNICODE);
    exit;
}

$repo = new \App\Repository\MaterialMatrixRepository($pdo);
$materials = $repo->listActiveMaterials();

echo json_encode($materials, JSON_UNESCAPED_UNICODE);
exit;
