@extends('layouts.app') @section('title', 'Statistiques Livreur') @push('styles') @endpush @section('content')
←
πŸ“Š Mes Statistiques
{{ number_format($allTimeStats['total_earnings'], 2) }}€
Gains totaux
{{ $allTimeStats['total_deliveries'] }}
Livraisons
{{ $allTimeStats['success_rate'] }}%
RΓ©ussite
{{ $allTimeStats['failed'] }}
Γ‰chouΓ©es
{{ number_format($allTimeStats['avg_rating'], 1) }}
Note moy.
@php $rating = $allTimeStats['avg_rating']; $stars = str_repeat('⭐', (int)round($rating)) . str_repeat('β˜†', 5 - (int)round($rating)); $rateClass = $rating >= 4 ? 'good' : ($rating >= 3 ? 'mid' : 'bad'); @endphp
{{ $stars }}
{{ number_format($rating, 1) }}/5
Note moyenne globale
πŸ“ˆ Cette semaine
@php $maxCount = $weeklyStats->max('count') ?: 1; $maxEarn = $weeklyStats->max('earnings') ?: 1; $days = ['Lun','Mar','Mer','Jeu','Ven','Sam','Dim']; $weekData = []; for($i = 6; $i >= 0; $i--) { $date = now()->subDays($i)->format('Y-m-d'); $dayName = $days[now()->subDays($i)->dayOfWeekIso - 1]; $found = $weeklyStats->firstWhere('date', $date); $weekData[] = [ 'day' => $dayName, 'count' => $found ? $found->count : 0, 'earnings' => $found ? $found->earnings : 0, ]; } @endphp
@foreach($weekData as $d)
{{ $d['count'] }}
{{ $d['day'] }}
@endforeach
Livraisons Total semaine: {{ $weeklyStats->sum('count') }} livr. β€” {{ number_format($weeklyStats->sum('earnings'), 2) }}€
πŸ“… Ce mois
{{ $monthlyStats->total ?? 0 }}
Livraisons
{{ number_format($monthlyStats->earnings ?? 0, 2) }}€
Gains
{{ number_format($monthlyStats->distance ?? 0, 1) }} km
Distance
~{{ (int)($monthlyStats->avg_time ?? 0) }} min
Temps moyen
πŸ• Heures de pointe (30 jours)
@php $maxPeak = $peakHours->max('count') ?: 1; $peakMap = $peakHours->keyBy('hour'); @endphp @for($h = 8; $h <= 23; $h++) @php $count = $peakMap->has($h) ? $peakMap[$h]->count : 0; $level = $maxPeak > 0 ? min(5, (int)ceil(($count / $maxPeak) * 5)) : 0; @endphp
{{ $h }}h
{{ $count }}
@if($peakMap->has($h))
{{ number_format($peakMap[$h]->earnings, 0) }}€
@endif
@endfor
πŸ’‘ Les heures vertes = plus de livraisons = plus de gains
@if($topRestaurants->count() > 0)
πŸ† Top Restaurants
@foreach($topRestaurants as $i => $rest)
{{ $i + 1 }}
{{ $rest->prestataire?->company_name ?? 'Restaurant' }}
{{ $rest->count }} livraisons
+{{ number_format($rest->earnings, 2) }}€
@endforeach
@endif
@endsection