@php $d = $this->getData(); $totalLeads = $d['totalLeads']; $wonLeads = $d['wonLeads']; $lostLeads = $d['lostLeads']; $pendingLeads = $d['pendingLeads']; $winRate = $d['overallWinRate']; $staleCount = $d['staleCount']; $conditionStages = $d['conditionStages']; $dealBreakdown = $d['dealBreakdown']; $monthlyData = $d['monthlyData']; $momGrowth = $d['momGrowth']; $platformCards = $d['platformCards']; $maxLeads = $d['maxLeads']; $maxRevenue = $d['maxRevenue']; // Tier config reused across tabs $tierConfig = [ 'good' => ['bg' => 'bg-emerald-50', 'border' => 'border-emerald-200', 'badge' => 'bg-emerald-100 text-emerald-700', 'ring' => '#10b981', 'track' => '#d1fae5', 'bar' => 'bg-emerald-400', 'label' => 'Good'], 'warning' => ['bg' => 'bg-amber-50', 'border' => 'border-amber-200', 'badge' => 'bg-amber-100 text-amber-700', 'ring' => '#f59e0b', 'track' => '#fef3c7', 'bar' => 'bg-amber-400', 'label' => 'Review'], 'danger' => ['bg' => 'bg-rose-50', 'border' => 'border-rose-200', 'badge' => 'bg-rose-100 text-rose-700', 'ring' => '#f43f5e', 'track' => '#ffe4e6', 'bar' => 'bg-rose-400', 'label' => 'At Risk'], ]; // Stage colours for pipeline $stageConfig = [ 'warm' => ['dot' => 'bg-emerald-400', 'bar' => 'bg-emerald-400', 'badge' => 'bg-emerald-100 text-emerald-700'], 'neutral' => ['dot' => 'bg-amber-400', 'bar' => 'bg-amber-400', 'badge' => 'bg-amber-100 text-amber-700'], 'cold' => ['dot' => 'bg-rose-400', 'bar' => 'bg-rose-400', 'badge' => 'bg-rose-100 text-rose-700'], ]; // Bar chart max for growth tab $maxMonthlyLeads = max(1, collect($monthlyData)->max('leads')); // Donut-style deal breakdown totals $dealTotal = max(1, array_sum($dealBreakdown)); @endphp Leads Overview Pipeline health, market growth trends and platform performance. {{-- ── Summary Banner ─────────────────────────────────────────────── --}}
{{-- Total Leads --}}
Total Leads {{ number_format($totalLeads) }}
{{-- Won --}}
Won {{ number_format($wonLeads) }}
{{-- Lost --}}
Lost {{ number_format($lostLeads) }}
{{-- Pending --}}
Pending {{ number_format($pendingLeads) }}
{{-- Win Rate --}}
Win Rate {{ $winRate }}%
{{-- Stale --}}
$staleCount > 0, 'border-gray-200 bg-gray-50' => $staleCount === 0, ])> $staleCount > 0, 'text-gray-500' => $staleCount === 0, ])>Stale Leads
$staleCount > 0, 'text-gray-700' => $staleCount === 0, ])>{{ $staleCount }} @if ($staleCount > 0) @endif
{{-- ── Alpine Tabs ─────────────────────────────────────────────────── --}}
{{-- Tab Nav --}}
{{-- ════════════════════════════════════════════════════════════ --}} {{-- TAB 1: PIPELINE --}} {{-- ════════════════════════════════════════════════════════════ --}}
@if ($totalLeads === 0)

No lead data for this period

Add leads or adjust the date range filter

@else
{{-- Stage Funnel --}}

Lead Stages

@foreach ($conditionStages as $stage) @php $sc = $stageConfig[$stage['type']]; @endphp
{{ $stage['name'] }} {{ ucfirst($stage['type']) }}
{{ $stage['count'] }} {{ $stage['pct'] }}%
@endforeach
{{-- Stage legend --}}
Warm (Active)
Neutral (Waiting)
Cold (Dead)
{{-- Right column: deal breakdown + stale alert --}}
{{-- Deal Status Donut Summary --}}

Deal Breakdown

@php $dealColors = [ 'Won' => ['bg' => 'bg-emerald-500', 'text' => 'text-emerald-700', 'light' => 'bg-emerald-100'], 'Lost' => ['bg' => 'bg-rose-500', 'text' => 'text-rose-700', 'light' => 'bg-rose-100'], 'Pending' => ['bg' => 'bg-amber-400', 'text' => 'text-amber-700', 'light' => 'bg-amber-100'], '—' => ['bg' => 'bg-gray-300', 'text' => 'text-gray-500', 'light' => 'bg-gray-100'], ]; // Build CSS gradient segments for the "donut" $gradientStops = []; $hardColors = ['Won' => '#10b981', 'Lost' => '#f43f5e', 'Pending' => '#f59e0b', '—' => '#d1d5db']; $cumPct = 0; foreach ($dealBreakdown as $status => $count) { $pct = $dealTotal > 0 ? round($count / $dealTotal * 100, 1) : 0; $color = $hardColors[$status] ?? '#d1d5db'; $gradientStops[] = "{$color} {$cumPct}% " . ($cumPct + $pct) . "%"; $cumPct += $pct; } $gradientCss = 'conic-gradient(' . implode(', ', $gradientStops) . ')'; @endphp {{-- CSS conic-gradient donut --}}
{{ $totalLeads }}
@foreach ($dealBreakdown as $status => $count) @php $dc = $dealColors[$status] ?? $dealColors['—']; $pct = $dealTotal > 0 ? round($count / $dealTotal * 100) : 0; @endphp
{{ $status }}
{{ $count }} {{ $pct }}%
@endforeach
{{-- Stale Leads Alert --}} @if ($staleCount > 0)

Stale Lead Alert

{{ $staleCount }} pending {{ $staleCount === 1 ? 'lead has' : 'leads have' }} had no interaction for over 7 days. Follow up before they go cold.

@else

All pending leads are being actively followed up.

@endif
@endif
{{-- ════════════════════════════════════════════════════════════ --}} {{-- TAB 2: GROWTH --}} {{-- ════════════════════════════════════════════════════════════ --}}
{{-- Header row with MoM badge --}}

Monthly Lead Volume — Last 6 Months

@if ($momGrowth !== null)
$momGrowth >= 0, 'bg-rose-100 text-rose-700' => $momGrowth < 0, ])> @if ($momGrowth >= 0) @else @endif MoM: {{ $momGrowth > 0 ? '+' : '' }}{{ $momGrowth }}%
@else Insufficient data for MoM @endif
{{-- Bar Chart --}}
@foreach ($monthlyData as $month) @php $barHeightPct = $maxMonthlyLeads > 0 ? round($month['leads'] / $maxMonthlyLeads * 100) : 0; $wonHeightPct = $maxMonthlyLeads > 0 ? round($month['won'] / $maxMonthlyLeads * 100) : 0; @endphp
{{-- Bars stacked side-by-side in a row --}}
{{-- Total leads bar --}}
{{-- Won bar --}}
{{-- Month label --}} {{ $month['label'] }}
@endforeach
{{-- Chart legend --}}
Total Leads
Won Deals
{{-- Monthly detail table --}}
@foreach ($monthlyData as $idx => $month) @php $prevLeads = $idx > 0 ? ($monthlyData[$idx - 1]['leads'] ?? 0) : null; $rowMom = null; if ($prevLeads !== null && $prevLeads > 0) { $rowMom = round((($month['leads'] - $prevLeads) / $prevLeads) * 100, 1); } elseif ($prevLeads !== null && $month['leads'] > 0) { $rowMom = 100.0; } @endphp @endforeach
Month Leads Won Win Rate MoM
{{ $month['label'] }} {{ $month['year'] }} {{ $month['leads'] }} {{ $month['won'] }} $month['winRate'] >= 30, 'bg-amber-100 text-amber-700' => $month['winRate'] >= 10 && $month['winRate'] < 30, 'bg-rose-100 text-rose-700' => $month['winRate'] < 10, ])>{{ $month['winRate'] }}% @if ($rowMom !== null) $rowMom >= 0, 'text-rose-600' => $rowMom < 0, ])>{{ $rowMom > 0 ? '+' : '' }}{{ $rowMom }}% @else @endif
{{-- ════════════════════════════════════════════════════════════ --}} {{-- TAB 3: PLATFORMS --}} {{-- ════════════════════════════════════════════════════════════ --}}
{{-- Summary banners --}} @php $topPlatform = collect($platformCards)->sortByDesc('score')->first(); $atRiskCount = collect($platformCards)->where('tier', 'danger')->count(); $warnCount = collect($platformCards)->where('tier', 'warning')->count(); @endphp @if (count($platformCards) > 0)
@if ($topPlatform)
Top platform: {{ $topPlatform['name'] }} — score {{ $topPlatform['score'] }}
@endif @if ($atRiskCount > 0)
{{ $atRiskCount }} platform{{ $atRiskCount > 1 ? 's' : '' }} at risk
@endif @if ($warnCount > 0)
{{ $warnCount }} under review
@endif
@endif @if (count($platformCards) === 0)

No platform data for this period

Add platforms or adjust the date range filter

@else
@foreach ($platformCards as $card) @php $tc = $tierConfig[$card['tier']]; $circumference = 2 * M_PI * 28; // r=28 $offset = $circumference - ($card['score'] / 100) * $circumference; $leadPct = $maxLeads > 0 ? min(100, round($card['leadCount'] / $maxLeads * 100)) : 0; $revPct = $maxRevenue > 0 ? min(100, round($card['revenue'] / $maxRevenue * 100)) : 0; @endphp
{{-- Card Header --}}

{{ $card['name'] }}

{{ $tc['label'] }}
{{-- Score Ring --}}
{{ $card['score'] }} / 100
{{-- Key Stats Grid --}}

Leads

{{ $card['leadCount'] }}

Won

{{ $card['wonCount'] }}

Win Rate

{{ $card['winRate'] }}%

Revenue

${{ number_format($card['revenue'], 0) }}

{{-- Progress Bars --}}
{{-- Lead volume bar --}}
Lead Volume {{ $card['leadCount'] }}
{{-- Revenue bar --}}
Revenue ${{ number_format($card['revenue'], 0) }}
{{-- Win rate bar --}}
Win Rate $card['winRate'] >= 30, 'bg-amber-100 text-amber-600' => $card['winRate'] >= 10 && $card['winRate'] < 30, 'bg-rose-100 text-rose-600' => $card['winRate'] < 10, ])>{{ $card['winRate'] }}%
{{-- Avg deal value --}} @if ($card['wonCount'] > 0)
Avg deal value: ${{ number_format($card['avgPrice'], 0) }}
@endif {{-- Insights --}} @if (count($card['insights']) > 0)
@foreach ($card['insights'] as $insight)
{{ $insight }}
@endforeach
@else
Platform performing well across all metrics
@endif
@endforeach
{{-- Scoring legend --}}
Good (score ≥ 70)
Review (score 40–69)
At Risk (score < 40)
Score = win rate (45%) + volume (30%) + avg price (25%). Bars relative to best performer.
@endif