@extends('admin.layouts.app')
@section('title', 'Revenue - Admin')
@section('page-title', 'Revenue & Sales Report')
@section('content')
{{-- Summary --}}
๐ฐ
Total Revenue
RM {{ number_format($totalRevenue, 2) }}
๐งพ
Total Orders
{{ $totalOrders }}
๐
Avg Order Value
RM {{ $totalOrders > 0 ? number_format($totalRevenue / $totalOrders, 2) : '0.00' }}
๐
This Month
RM {{ number_format($monthlySales->firstWhere('month', now()->month)?->total ?? 0, 2) }}
{{-- Monthly Chart --}}
๐ Monthly Sales ({{ now()->year }})
@php
$months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
$maxSale = $monthlySales->max('total') ?: 1;
@endphp
@foreach($months as $i => $month)
@php
$sale = $monthlySales->firstWhere('month', $i + 1);
$height = $sale ? ($sale->total / $maxSale) * 140 : 0;
@endphp
RM {{ number_format($sale->total ?? 0, 0) }}
{{ $month }}
@endforeach
{{-- Monthly Breakdown --}}