<?php
require 'middleware.php';

$stmt = $pdo->prepare("
SELECT SUM(estimated_price) as total
FROM bookings
WHERE driver_id=? AND status='completed'
");
$stmt->execute([$driver_id]);

$total = $stmt->fetchColumn() ?? 0;

echo json_encode(['earnings'=>$total]);
