@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

Admin Dashboard

Live platform overview for users, content, subscriptions, and revenue.

+ Add New Movie

Total Users

{{ \App\Models\User::count() }}

Total Movies

{{ \App\Models\Movie::count() }}

Active Subs

{{ $activeSubscriptions ?? 0 }}

Monthly Revenue

GH₵{{ number_format($monthlyRevenue ?? 0, 2) }}

Monthly Revenue

Current month earnings snapshot

Total

GH₵{{ number_format((float) $monthlyRevenueValue, 2) }}

Weekly Revenue

Track income flow across the week

This Week

GH₵{{ number_format((float) $weeklyRevenueValue, 2) }}

Recent Transactions

Latest payment activity on the platform

@forelse($recentTransactions as $transaction) @php $transactionUserName = $transaction->user_name ?? $transaction->name ?? $transaction->email ?? 'N/A'; $transactionStatus = strtolower((string)($transaction->status ?? 'pending')); @endphp @empty @endforelse
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

Latest Users

Most recently registered accounts

    @forelse($latestUsers as $user)
  • {{ $user->name ?? 'User' }}

    {{ $user->email ?? 'No email' }}

    @if(!empty($user->created_at)) {{ $user->created_at->diffForHumans() }} @endif
  • @empty
  • No users found
  • @endforelse
@endsection @push('scripts') @endpush