@php /** @var array $aggregate */ /** @var \Illuminate\Support\Collection $picker */ $a = $aggregate ?? []; $kfmt = function ($n) { if ($n >= 1_000_000) { return number_format($n / 1_000_000, 1) . 'm'; } if ($n >= 1_000) { return number_format($n / 1_000, 1) . 'k'; } return number_format($n); }; $fmt = fn($n, $d = 0) => number_format($n, $d); $hasData = ($a['total_campaigns'] ?? 0) > 0; $goalLabels = [ 'MESSAGES' => 'Messages', 'LINK_CLICKS' => 'Link clicks', 'LEAD_GENERATION' => 'Lead gen', 'CONVERSIONS' => 'Conversions', 'BRAND_AWARENESS' => 'Brand awareness', 'REACH' => 'Reach', 'VIDEO_VIEWS' => 'Video views', ]; @endphp @if (!$hasData)
@include('user.partials.empty-state', [ 'class' => 'max-w-2xl mx-auto', 'message' => 'No Meta Ads campaign data found. Create your first campaign and analytics will appear as soon as it starts spending.', 'resetHref' => url('/meta-ads'), 'resetLabel' => 'Back to Meta Ads', 'actionHref' => route('user.meta-ads.create'), 'actionLabel' => 'Create campaign', ])
@else
{{-- Hero band — workspace-wide totals --}}
{{ __('Workspace') }} {{ $a['total_campaigns'] }} campaign{{ $a['total_campaigns'] === 1 ? '' : 's' }} · {{ $a['active'] }} {{ __('active') }}

{{ __('Meta Ads') }} {{ __('analytics') }}

{{ __('Aggregate performance across every campaign in this workspace. Click any row in the table below to drill into a specific campaign.') }}

{{ __('ROAS') }}
{{ $fmt($a['roas'], 2) }}x
{{ __('Spend') }}
${{ $kfmt($a['spend']) }}
{{ __('Revenue') }}
${{ $kfmt($a['revenue']) }}
{{ __('Leads') }}
{{ $fmt($a['conversions']) }}
{{ __('CPL') }}
${{ $fmt($a['cpl'], 2) }}
{{ __('CTR') }}
{{ $fmt($a['ctr'], 2) }}%
{{-- Workspace-wide metric grid --}}
{{ __('Impressions') }}
{{ $kfmt($a['impressions']) }}
{{ __('across all campaigns') }}
{{ __('Reach') }}
{{ $kfmt($a['reach']) }}
{{ $a['impressions'] && $a['reach'] ? $fmt($a['impressions'] / max($a['reach'], 1), 2) : '0.00' }}× frequency
{{ __('Clicks') }}
{{ $fmt($a['clicks']) }}
${{ $fmt($a['cpc'], 2) }} CPC
{{ __('Active campaigns') }}
{{ $a['active'] }}
{{ $a['paused'] }} paused · {{ $a['scheduled'] }} {{ __('scheduled') }}
{{ __('Qualified leads') }}
{{ $fmt($a['conversions']) }}
${{ $fmt($a['cpl'], 2) }} {{ __('per lead') }}
{{ __('ROAS') }}
{{ $fmt($a['roas'], 2) }}x
${{ $kfmt($a['revenue']) }} on ${{ $kfmt($a['spend']) }}
{{-- Top campaigns by ROAS --}}
{{ __('Top performers') }}

{{ __('Highest ROAS campaigns') }}

{{ __('All campaigns') }}
@if (count($a['top']))
@foreach ($a['top'] as $row) @endforeach
{{ __('Campaign') }} {{ __('Goal') }} {{ __('Spend') }} {{ __('Leads') }} {{ __('ROAS') }}
{{ $row['name'] }}
{{ ucfirst(strtolower($row['status'])) }}
{{ $goalLabels[$row['goal']] ?? $row['goal'] }} ${{ $fmt($row['spend'], 2) }} {{ $fmt($row['leads']) }} {{ $fmt($row['roas'], 2) }}x Drill in →
@else
{{ __('No campaigns have spent yet.') }}
@endif
{{-- Spend mix by objective --}}
{{ __('Mix by objective') }}

{{ __('Spend share') }}

@php $maxSpend = collect($a['by_goal'])->max('spend') ?: 1; @endphp
@forelse ($a['by_goal'] as $goal => $row) @php $pct = $maxSpend ? ($row['spend'] / $maxSpend * 100) : 0; @endphp
{{ $goalLabels[$goal] ?? $goal }} ${{ $fmt($row['spend'], 2) }} · {{ $row['count'] }} run · {{ $row['leads'] }} lead{{ $row['leads'] === 1 ? '' : 's' }}
@empty

{{ __('No spend yet.') }}

@endforelse
{{-- Status breakdown --}}
{{ __('Status') }}

{{ __('Active') }}

{{ $a['active'] }}

{{ __('campaigns currently delivering') }}

{{ __('Status') }}

{{ __('Paused') }}

{{ $a['paused'] }}

{{ __('runs you can re-activate') }}

{{ __('Status') }}

{{ __('Scheduled') }}

{{ $a['scheduled'] }}

{{ __('queued for a future date') }}

@endif