@extends('layouts.admin') @section('title', 'Dashboard') @section('content')

Dashboard

Last updated: {{ now()->format('d M Y, H:i') }}

Total Users

{{ number_format($stats['total_users']) }}

{{ $stats['new_users_today'] ?? 0 }} new today

Total Orders

{{ number_format($stats['total_orders']) }}

{{ $stats['pending_orders'] }} pending

Total Products

{{ number_format($stats['total_products']) }}

{{ $stats['active_products'] ?? $stats['total_products'] }} active

Revenue

{{ currency($stats['total_revenue']) }}

{{ $stats['orders_today'] ?? 0 }} orders today

Pending Orders

{{ number_format($stats['pending_orders']) }}

Processing Orders

{{ number_format($stats['processing_orders'] ?? 0) }}

Delivered Orders

{{ number_format($stats['delivered_orders'] ?? 0) }}

Recent Orders

View All
@forelse($stats['recent_orders'] as $order) @empty @endforelse
Order # Customer Products Total Status Date Action
{{ $order->order_number }}
{{ $order->user ? substr($order->user->username, 0, 1) : 'G' }}

{{ $order->user->username ?? 'Guest' }}

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

@php $orderItems = App\Models\OrderItem::where('order_id', $order->id)->with('product.game')->get(); @endphp @foreach($orderItems->take(2) as $item)
{{ $item->product->name ?? 'Deleted' }} ×{{ $item->quantity }} @if($item->product && $item->product->game) {{ $item->product->game->name }} @endif
@endforeach @if($orderItems->count() > 2) +{{ $orderItems->count() - 2 }} more @endif
{{ currency($order->total) }} @if($order->subtotal != $order->total) {{ currency($order->subtotal) }} @endif {{ ucfirst($order->status) }} {{ $order->created_at->format('d M Y, H:i') }} View

No orders yet

Orders will appear here once customers start purchasing

Top Selling Products

@php $topProducts = App\Models\OrderItem::select('product_id', \DB::raw('SUM(quantity) as total_sold')) ->with('product.game') ->groupBy('product_id') ->orderBy('total_sold', 'desc') ->limit(5) ->get(); @endphp @if($topProducts->count() > 0)
@foreach($topProducts as $item)
{{ $loop->iteration }}

{{ $item->product->name ?? 'Deleted' }}

{{ $item->product->game->name ?? 'No Game' }}

{{ number_format($item->total_sold) }} sold

{{ currency($item->product->price ?? 0) }}

@endforeach
@else

No product sales data yet.

@endif
@endsection