@php $hour = (int) now()->format('H'); $greeting = match (true) { $hour >= 5 && $hour < 11 => 'Selamat Pagi', $hour >= 11 && $hour < 15 => 'Selamat Siang', $hour >= 15 && $hour < 18 => 'Selamat Sore', default => 'Selamat Malam', }; $userName = auth()->user()?->name ?? 'Super Admin'; $today = now()->translatedFormat('l, d F Y'); // SaaS Stats $totalTenants = \App\Models\Tenant::count(); $activeTenants = \App\Models\Tenant::where('status', 'active')->count(); $trialTenants = \App\Models\Tenant::where('status', 'active') ->whereNotNull('trial_ends_at') ->where('trial_ends_at', '>', now()) ->count(); // Monthly Recurring Revenue from active subscriptions $mrr = \App\Models\Subscription::where('status', 'active') ->where(function ($query) { $query->whereNull('ends_at') ->orWhere('ends_at', '>', now()); }) ->where('billing_cycle', 'monthly') ->sum('amount'); // Add yearly subscriptions divided by 12 $yearlyAsMonthly = \App\Models\Subscription::where('status', 'active') ->where(function ($query) { $query->whereNull('ends_at') ->orWhere('ends_at', '>', now()); }) ->where('billing_cycle', 'yearly') ->sum('amount'); $totalMrr = (float) $mrr + ((float) $yearlyAsMonthly / 12); $pendingUpgrades = \App\Models\UpgradeRequest::where('status', 'pending')->count(); // Recent tenants registered (limit 5) $recentTenants = \App\Models\Tenant::orderByDesc('created_at') ->limit(5) ->get(['id', 'name', 'slug', 'status', 'created_at']); // Recent subscriptions (limit 5) $recentSubscriptions = \App\Models\Subscription::with(['tenant', 'plan']) ->orderByDesc('created_at') ->limit(5) ->get(); // Chart data: 30 hari terakhir $chartLabels = []; $chartTenants = []; $chartUpgrades = []; $maxChartValue = 1; for ($i = 29; $i >= 0; $i--) { $date = now()->subDays($i); $chartLabels[] = $date->format('d M'); $dayTenants = (int) \App\Models\Tenant::whereDate('created_at', $date->format('Y-m-d'))->count(); $chartTenants[] = $dayTenants; $dayUpgrades = (int) \App\Models\UpgradeRequest::whereDate('created_at', $date->format('Y-m-d'))->count(); $chartUpgrades[] = $dayUpgrades; $maxChartValue = max($maxChartValue, $dayTenants, $dayUpgrades); } @endphp {{-- Header / Greeting Card --}}

{{ $greeting }}, {{ $userName }} 👋

SaaS Super Admin Portal — {{ $today }}

{{-- KPI Cards Grid --}}
{{-- Total Tenant --}}
Total Tenant

{{ number_format($totalTenants) }}

Pendaftaran keseluruhan

{{-- Tenant Aktif --}}
Tenant Aktif

{{ number_format($activeTenants) }}

{{ round($totalTenants > 0 ? ($activeTenants / $totalTenants) * 100 : 0, 1) }}% aktif

{{-- Monthly Recurring Revenue (MRR) --}}
SaaS MRR

Rp {{ number_format($totalMrr, 0, ',', '.') }}

Recurring revenue bulanan

{{-- Tenant Trial --}}
Tenant Trial

{{ number_format($trialTenants) }}

Masa uji coba gratis

{{-- Pending Upgrades --}}
Pending Upgrade

{{ number_format($pendingUpgrades) }}

Menunggu persetujuan

{{-- Quick Actions --}}
Kelola Tenant Langganan Paket SaaS Upgrade Request Chat Tenant
{{-- SaaS Growth Chart --}}

Tren Pertumbuhan SaaS

Statistik Registrasi Tenant & Upgrade Request (30 Hari Terakhir)

@script @endscript {{-- Modern Tables Grid --}}
{{-- Recent Tenants --}}

Pendaftaran Tenant Terbaru

@if($recentTenants->count() > 0) @foreach($recentTenants as $t) @endforeach
Nama Toko Slug Status Tanggal Daftar
{{ $t->name }} {{ $t->slug }} {{ ucfirst($t->status) }} {{ $t->created_at->format('d/m/Y') }}
@else
Belum ada pendaftaran tenant baru.
@endif
{{-- Recent Subscriptions --}}

Transaksi Berlangganan Terbaru

@if($recentSubscriptions->count() > 0) @foreach($recentSubscriptions as $sub) @endforeach
Tenant Paket Nilai Status
{{ $sub->tenant?->name ?? '-' }} {{ $sub->plan?->name ?? '-' }} Rp {{ number_format($sub->amount, 0, ',', '.') }} {{ ucfirst($sub->status) }}
@else
Belum ada transaksi langganan terbaru.
@endif