Overview
@php
$leads = $this->leads;
$total = $leads->count();
$today = $leads->filter(fn ($l) => $l->created_at?->isToday())->count();
$last7 = $leads->filter(fn ($l) => $l->created_at?->gte(now()->subDays(7)))->count();
$totalValue = $leads->sum('value');
$avgValue = $total ? $totalValue / $total : 0;
$byStatus = $leads->groupBy('status')->map->count();
@endphp
{{-- TOP METRICS --}}
Total
{{ number_format($total) }}
Today
{{ number_format($today) }}
Last 7 Days
{{ number_format($last7) }}
Total Value
£{{ number_format($totalValue, 2) }}
Avg £{{ number_format($avgValue, 2) }}
{{-- STATUS BREAKDOWN --}}
Status Breakdown
@if($total === 0)
No leads in this range
@else
@foreach($byStatus as $status => $count)
@php
$percent = round(($count / $total) * 100);
$label = ucfirst(str_replace('_', ' ', $status));
@endphp
{{ $label }}
{{ $percent }}%
{{ number_format($count) }} leads
@endforeach
@endif