@php $platformSvgs = [ 'twitter' => '', 'facebook' => '', 'instagram' => '', 'linkedin' => '', 'tiktok' => '', 'youtube' => '', 'pinterest' => '', 'threads' => '', ]; $platformColors = [ 'twitter' => '#1d9bf0', 'facebook' => '#1877f2', 'instagram' => '#e1306c', 'linkedin' => '#0a66c2', 'tiktok' => '#010101', 'youtube' => '#ff0000', 'pinterest' => '#e60023', 'threads' => '#000000', ]; $subNavItems = [ ['label' => 'Streams', 'icon' => 'M4 6h16M4 10h16M4 14h16M4 18h16', 'href' => route('dashboard')], ['label' => 'Publisher', 'icon' => 'M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z', 'href' => '/compose'], ['label' => 'Calendar', 'icon' => 'M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z', 'href' => route('calendar')], ['label' => 'Inbox', 'icon' => 'M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4', 'href' => route('inbox')], ['label' => 'Content', 'icon' => 'M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10', 'href' => '/library'], ['label' => 'Settings', 'icon' => 'M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065zM15 12a3 3 0 11-6 0 3 3 0 016 0z', 'href' => route('social.accounts')], ]; $bestHours = [ ['hour' => '9 AM', 'score' => 87, 'label' => 'High engagement'], ['hour' => '12 PM', 'score' => 94, 'label' => 'Peak time'], ['hour' => '6 PM', 'score' => 82, 'label' => 'Good reach'], ['hour' => '9 PM', 'score' => 71, 'label' => 'Moderate'], ]; @endphp
{{-- ── Left sub-navigation ──────────────────────────────── --}}

Navigate

{{-- Analytics highlighted at top --}} Analytics @foreach($subNavItems as $item) {{ $item['label'] }} @endforeach
{{-- ── Main content area ────────────────────────────────── --}}
{{-- Page header + date controls --}}

Analytics Overview

Track performance across all connected platforms

{{-- Preset buttons --}} @foreach(['7d' => '7 Days', '30d' => '30 Days', '90d' => '90 Days'] as $key => $label) @endforeach {{-- Custom date range --}}
{{-- Export --}}
{{-- ── KPI Cards ──────────────────────────────────────── --}}
@php $kpiCards = [ [ 'label' => 'Posts Sent', 'value' => number_format($kpis['total_posts']), 'change' => null, 'icon' => 'M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z', 'color' => 'text-blue-600 bg-blue-50', ], [ 'label' => 'Published', 'value' => number_format($kpis['published_posts']), 'change' => null, 'icon' => 'M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z', 'color' => 'text-green-600 bg-green-50', ], [ 'label' => 'Impressions', 'value' => $kpis['total_impressions'] >= 1000 ? number_format($kpis['total_impressions'] / 1000, 1) . 'K' : number_format($kpis['total_impressions']), 'change' => null, 'icon' => 'M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z', 'color' => 'text-purple-600 bg-purple-50', ], [ 'label' => 'Engagement', 'value' => number_format($kpis['total_engagement']), 'change' => $kpis['engagement_change'], 'icon' => 'M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z', 'color' => 'text-rose-600 bg-rose-50', ], [ 'label' => 'Clicks', 'value' => number_format($kpis['total_clicks']), 'change' => null, 'icon' => 'M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122', 'color' => 'text-amber-600 bg-amber-50', ], ]; @endphp @foreach($kpiCards as $card)

{{ $card['label'] }}

{{ $card['value'] }}

@if($card['change'] !== null)
{{ abs($card['change']) }}% vs prev period
@else

in period

@endif
@endforeach
{{-- ── Chart + Right panels ─────────────────────────── --}}
{{-- Chart section --}}
{{-- Engagement line chart --}}

Engagement Over Time

Engagements
{{-- Platform breakdown --}}

Platform Breakdown

@if($platformBreakdown->isEmpty())

No analytics data yet. Publish posts to see breakdown.

@else
@foreach($platformBreakdown as $item) @php $pVal = $item['platform']; $pColor = $platformColors[$pVal] ?? '#9ca3af'; $pSvg = $platformSvgs[$pVal] ?? ''; $maxEngage = $platformBreakdown->max('engagement') ?: 1; $barPct = $maxEngage > 0 ? round($item['engagement'] / $maxEngage * 100) : 0; @endphp
{!! $pSvg !!}

{{ $item['label'] }}

{{ $item['posts'] }} posts

{{ number_format($item['impressions']) }}

Impr.

{{ number_format($item['engagement']) }}

Engage.

@endforeach
@endif
{{-- ── Right panels (260px) ─────────────────────────── --}}
{{-- Best time to post --}}

Best Times to Post

@foreach($bestHours as $slot)

{{ $slot['hour'] }}

{{ $slot['label'] }}

{{ $slot['score'] }}
@endforeach

Based on your audience activity patterns across all connected accounts.

{{-- Quick insights --}}

Insights

@if($kpis['engagement_change'] > 0)

Engagement Up

+{{ $kpis['engagement_change'] }}% compared to the previous period. Keep it up!

@elseif($kpis['engagement_change'] < 0)

Engagement Down

{{ $kpis['engagement_change'] }}% vs previous period. Try posting at peak times.

@else

No comparison data

Publish more posts to unlock trend insights.

@endif

Tip

Post at 12 PM for maximum reach based on your audience data.

@if($kpis['published_posts'] === 0)

Get started

Create your first post to start collecting analytics.

@endif
{{-- Reports quick-links --}}

Reports

@foreach(['Overview', 'Engagement', 'Audience', 'Post Performance'] as $report) @endforeach
{{-- ── Top Posts table ──────────────────────────────── --}}

Top Performing Posts

Sorted by {{ ucfirst($sortBy) }} {{ $sortDir === 'desc' ? '(high to low)' : '(low to high)' }}
@if($topPosts->isEmpty())

No published posts in this date range.

@else
@foreach($topPosts as $post) @php $pVal = $post->socialAccount?->platform?->value ?? ''; $pColor = $platformColors[$pVal] ?? '#9ca3af'; $pSvg = $platformSvgs[$pVal] ?? ''; @endphp @endforeach
Post Date @if($sortBy === 'date'){{ $sortDir === 'asc' ? '↑' : '↓' }}@endif Likes @if($sortBy === 'likes'){{ $sortDir === 'asc' ? '↑' : '↓' }}@endif Comments @if($sortBy === 'comments'){{ $sortDir === 'asc' ? '↑' : '↓' }}@endif Shares @if($sortBy === 'shares'){{ $sortDir === 'asc' ? '↑' : '↓' }}@endif Impressions @if($sortBy === 'impressions'){{ $sortDir === 'asc' ? '↑' : '↓' }}@endif Eng. Rate @if($sortBy === 'engagement'){{ $sortDir === 'asc' ? '↑' : '↓' }}@endif
{!! $pSvg !!}

{{ mb_substr(strip_tags($post->content?->caption ?? 'No caption'), 0, 60) }}

{{ $post->published_at?->format('M d, Y') ?? '—' }} {{ number_format($post->latestAnalytics?->likes ?? 0) }} {{ number_format($post->latestAnalytics?->comments ?? 0) }} {{ number_format($post->latestAnalytics?->shares ?? 0) }} {{ number_format($post->latestAnalytics?->impressions ?? 0) }} @php $rate = $post->latestAnalytics?->engagement_rate ?? 0; @endphp {{ $rate }}%
@if($topPosts->hasPages())
{{ $topPosts->links() }}
@endif @endif
@push('scripts') @endpush