@extends('admin.layouts.app') @section('content') @php use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; $totalUsersValue = class_exists(\App\Models\User::class) ? \App\Models\User::count() : 0; $totalMoviesValue = class_exists(\App\Models\Movie::class) ? \App\Models\Movie::count() : 0; $activeSubsValue = 0; if (Schema::hasTable('subscriptions')) { try { if (Schema::hasColumn('subscriptions', 'status')) { $activeSubsValue = DB::table('subscriptions') ->whereIn('status', ['active', 'ACTIVE', 'Active']) ->count(); } elseif (Schema::hasColumn('subscriptions', 'is_active')) { $activeSubsValue = DB::table('subscriptions')->where('is_active', 1)->count(); } else { $activeSubsValue = DB::table('subscriptions')->count(); } } catch (\Throwable $e) { $activeSubsValue = 0; } } elseif (Schema::hasTable('user_subscriptions')) { try { if (Schema::hasColumn('user_subscriptions', 'status')) { $activeSubsValue = DB::table('user_subscriptions') ->whereIn('status', ['active', 'ACTIVE', 'Active']) ->count(); } elseif (Schema::hasColumn('user_subscriptions', 'is_active')) { $activeSubsValue = DB::table('user_subscriptions')->where('is_active', 1)->count(); } else { $activeSubsValue = DB::table('user_subscriptions')->count(); } } catch (\Throwable $e) { $activeSubsValue = 0; } } $monthlyRevenueValue = 0; $weeklyRevenueValue = 0; foreach (['transactions', 'payments'] as $table) { if (!Schema::hasTable($table)) { continue; } try { $monthlyQuery = DB::table($table); $weeklyQuery = DB::table($table); if (Schema::hasColumn($table, 'status')) { $statuses = ['success', 'successful', 'paid', 'completed', 'SUCCESS']; $monthlyQuery->whereIn('status', $statuses); $weeklyQuery->whereIn('status', $statuses); } if (Schema::hasColumn($table, 'created_at')) { $monthlyQuery->whereBetween('created_at', [now()->startOfMonth(), now()->endOfMonth()]); $weeklyQuery->whereBetween('created_at', [now()->startOfWeek(), now()->endOfWeek()]); } if (Schema::hasColumn($table, 'amount')) { $monthlyRevenueValue = (float) $monthlyQuery->sum('amount'); $weeklyRevenueValue = (float) $weeklyQuery->sum('amount'); break; } } catch (\Throwable $e) { $monthlyRevenueValue = 0; $weeklyRevenueValue = 0; } } $recentTransactions = collect(); foreach (['transactions', 'payments'] as $table) { if (!Schema::hasTable($table)) { continue; } try { $query = DB::table($table); if (Schema::hasColumn($table, 'created_at')) { $query->orderByDesc('created_at'); } elseif (Schema::hasColumn($table, 'id')) { $query->orderByDesc('id'); } $recentTransactions = $query->limit(8)->get(); break; } catch (\Throwable $e) { $recentTransactions = collect(); } } $latestUsers = class_exists(\App\Models\User::class) ? \App\Models\User::latest()->take(8)->get() : collect(); $weeklyChartLabels = ['This Week']; $weeklyChartData = [$weeklyRevenueValue]; @endphp
Live platform overview for users, content, subscriptions, and revenue.
{{ \App\Models\User::count() }}
{{ \App\Models\Movie::count() }}
{{ $activeSubscriptions ?? 0 }}
GH₵{{ number_format($monthlyRevenue ?? 0, 2) }}
Current month earnings snapshot
Total
GH₵{{ number_format((float) $monthlyRevenueValue, 2) }}
Track income flow across the week
This Week
GH₵{{ number_format((float) $weeklyRevenueValue, 2) }}
Latest payment activity on the platform
| User | Amount | Status |
|---|---|---|
|
{{ $transactionUserName }}
@if(!empty($transaction->email))
{{ $transaction->email }}
@endif
|
GH₵{{ number_format((float)($transaction->amount ?? 0), 2) }} | {{ ucfirst($transaction->status ?? 'pending') }} |
| No transactions found | ||
Most recently registered accounts
{{ $user->name ?? 'User' }}
{{ $user->email ?? 'No email' }}