<?php
// list_vehicles.php
header('Content-Type: application/json');
require_once __DIR__ . '/config/db.php';

try {
    $stmt = $pdo->query(
        'SELECT id, model, license_plate, capacity
         FROM vehicles'
    );
    $vehicles = $stmt->fetchAll(PDO::FETCH_ASSOC);
    echo json_encode($vehicles);
} catch (PDOException $e) {
    http_response_code(500);
    echo json_encode(['error' => $e->getMessage()]);
}
