mirror of
https://github.com/Floriansylvain/Exo-technique-VIE-Barcelone-SaaS-HRTech.git
synced 2026-08-19 19:53:23 +02:00
feat: initial impl w/ styles, scripts, & server-side logic (steps 1, 2, 3)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user