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

Welcome back, {{ Auth::user()->name }}!

Here's what's happening with your stores today.

Total Stores

{{ Auth::user()->stores ? Auth::user()->stores->count() : 0 }}

Active Orders

@php $activeOrders = 0; if (Auth::user()->stores && Auth::user()->stores->count() > 0) { $activeOrders = Auth::user()->stores->sum(function($store) { return $store->orders()->whereIn('status', ['pending', 'processing'])->count(); }); } @endphp {{ $activeOrders }}

Total Revenue

@php $totalRevenue = 0; if (Auth::user()->stores && Auth::user()->stores->count() > 0) { $totalRevenue = Auth::user()->stores->sum(function($store) { return $store->orders()->whereIn('status', ['completed', 'shipped'])->sum('total_amount'); }); } @endphp ${{ number_format($totalRevenue, 2) }}

Pending Orders

@php $pendingOrders = 0; if (Auth::user()->stores && Auth::user()->stores->count() > 0) { $pendingOrders = Auth::user()->stores->sum(function($store) { return $store->orders()->where('status', 'pending')->count(); }); } @endphp {{ $pendingOrders }}

Recent Orders

@php $recentOrders = collect(); if (Auth::user()->stores && Auth::user()->stores->count() > 0) { $recentOrders = Auth::user()->stores->flatMap(function($store) { return $store->orders; })->sortByDesc('created_at')->take(5); } @endphp @if($recentOrders->count() > 0)
@foreach($recentOrders as $order) @endforeach
Order ID Store Customer Amount Status Date
#{{ $order->id }} {{ $order->store?->name ?? 'N/A' }} {{ $order->customer_name }} ${{ number_format($order->total_amount, 2) }} {{ ucfirst($order->status) }} {{ $order->created_at->format('M d, Y') }}
@else

No orders yet

Get started by creating your first store.

@endif
@endsection