'printer id missing'], JSON_UNESCAPED_UNICODE); exit; } $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); $printer = $repo->getPrinterById($printerId); if (!$printer) { http_response_code(404); echo json_encode(['error' => 'printer not found'], JSON_UNESCAPED_UNICODE); exit; } $materials = $repo->listMaterialsForPrinter($printerId); echo json_encode([ 'printer' => $printer, 'materials' => $materials, ], JSON_UNESCAPED_UNICODE); exit;