feat: initial impl w/ styles, scripts, & server-side logic (steps 1, 2, 3)

This commit is contained in:
Floriansylvain
2025-12-16 21:09:53 +01:00
parent 9e00c10b9c
commit dbce932ce2
15 changed files with 501 additions and 7 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
class DataManager
{
private static function readJsonFile(string $filename): array
{
$path = __DIR__ . '/../data/' . $filename;
if (!file_exists($path)) {
return [];
}
$content = file_get_contents($path);
$data = json_decode($content, true);
return is_array($data) ? $data : [];
}
public static function getCars(string $clientId): array
{
$cars = self::readJsonFile('cars.json');
return array_values(array_filter($cars, fn($c) => isset($c['customer']) && $c['customer'] === $clientId));
}
public static function getGarages(string $clientId): array
{
$garages = self::readJsonFile('garages.json');
return array_values(array_filter($garages, fn($g) => isset($g['customer']) && $g['customer'] === $clientId));
}
public static function getGarageById($id): ?array
{
$garages = self::readJsonFile('garages.json');
foreach ($garages as $g) {
if (isset($g['id']) && $g['id'] == $id) {
return $g;
}
}
return null;
}
}