@php // Tiny inline sparkline for the KPI cards. $spark = function (array $pts, string $color) { $max = max($pts) ?: 1; $min = min($pts); $w = 100; $h = 30; $n = count($pts); $coords = []; foreach ($pts as $i => $v) { $x = $n <= 1 ? 0 : $i / ($n - 1) * $w; $y = $h - ($max == $min ? 0.5 : ($v - $min) / ($max - $min)) * ($h - 4) - 2; $coords[] = round($x, 1).','.round($y, 1); } return ''; }; $kpiCards = [ ['icon' => 'users', 'tint' => '#7c3aed', 'label' => 'Total Users', 'value' => number_format($kpis['total_users']), 'delta' => 12.4, 'up' => true, 'spark' => [4,6,5,7,8,7,9]], ['icon' => 'crown', 'tint' => '#f59e0b', 'label' => 'Active Subscriptions', 'value' => number_format($kpis['active_subscriptions']), 'delta' => 9.8, 'up' => true, 'spark' => [3,4,4,5,6,7,8]], ['icon' => 'dollar-sign', 'tint' => '#22c55e', 'label' => 'Total Revenue', 'value' => '$'.number_format($kpis['mrr']), 'delta' => 18.2, 'up' => true, 'spark' => [5,6,6,8,7,9,11]], ['icon' => 'send', 'tint' => '#3b82f6', 'label' => 'Total Posts Today', 'value' => number_format($kpis['posts_today']), 'delta' => 24.6, 'up' => true, 'spark' => [6,7,8,7,9,10,12], 'sub' => 'vs yesterday'], ['icon' => 'layers', 'tint' => '#8b5cf6', 'label' => 'Platform Accounts', 'value' => number_format($kpis['connected_accounts']), 'delta' => 16.8, 'up' => true, 'spark' => [4,5,6,6,7,8,9]], ['icon' => 'shield-check', 'tint' => '#22c55e', 'label' => 'System Uptime', 'value' => $kpis['uptime'].'%', 'delta' => null, 'up' => true, 'spark' => [9,9,10,9,10,10,10], 'ok' => 'Operational'], ]; $donutTotal = collect($plans)->sum('count'); $statusColor = ['active' => 'text-green-400', 'suspended' => 'text-red-400', 'pending' => 'text-amber-400']; $planBadge = ['Pro' => 'text-amber-400 bg-amber-500/10', 'Business' => 'text-blue-400 bg-blue-500/10', 'Agency' => 'text-pink-400 bg-pink-500/10', 'Free' => 'text-slate-400 bg-slate-500/10']; @endphp
{{-- Title row --}}

Admin Dashboard

Complete overview of your CC Publisher SaaS platform

@can('users.manage') Create User @endcan
{{-- KPI cards --}}
@foreach ($kpiCards as $c)
{{ $c['label'] }}
{{ $c['value'] }}
@if (! is_null($c['delta'])) {{ $c['delta'] }}% {{ $c['sub'] ?? 'this month' }} @elseif (! empty($c['ok'])) {{ $c['ok'] }} @endif
{!! $spark($c['spark'], $c['tint']) !!}
@endforeach
{{-- Charts + Recent Activity --}}
{{-- Revenue --}}

Revenue Overview

{{-- Users Growth --}}

Users Growth

New Users Active Users
{{-- Recent Activity --}}

Recent Activity

View All
@forelse ($recent as $log)
{{ $log->description ?? $log->action }}
{{ $log->causer?->email ?? 'system' }}
{{ $log->created_at->diffForHumans(null, true) }}
@empty
No activity yet.
@endforelse
{{-- Distribution + Platform Usage + System Health --}}
{{-- Subscriptions by Plan --}}

Subscriptions by Plan

{{ number_format($donutTotal) }}
Active
@foreach ($plans as $p)
{{ $p['name'] }} {{ $p['pct'] }}% ({{ number_format($p['count']) }})
@endforeach
{{-- Platform Usage --}}

Platform Usage

@foreach ($platforms as $pf)
{{ strtoupper(substr($pf['label'], 0, 2)) }} {{ $pf['label'] }}
{{ number_format($pf['count']) }} {{ $pf['pct'] }}%
@endforeach
{{-- System Health --}}

System Health

All Operational
@foreach ($health as $h)
{{ $h['label'] }}
{{ $h['value'] }}
{{ $h['ok'] ? 'Healthy' : 'Down' }}
@endforeach
{{-- Recent Users + Global Statistics --}}
{{-- Recent Users --}}

Recent Users

View All
@forelse ($recentUsers as $u) @empty @endforelse
User Plan Accounts Posts Today Status Joined
{{ strtoupper(substr($u['name'] ?: $u['email'], 0, 1)) }}
{{ $u['name'] }}
{{ $u['email'] }}
{{ $u['plan'] }} {{ $u['accounts'] }} {{ number_format($u['posts_today']) }} {{ ucfirst($u['status']) }} {{ $u['joined'] }}
No users yet.
{{-- Global Statistics --}}

Global Statistics

View Report
{{ number_format($globalStats['users_worldwide']) }}
Users Worldwide
{{ $globalStats['countries'] }}
Countries
{{ number_format($globalStats['posts_today']) }}
Posts Today
@script @endscript