@extends('backend.layout.master-tailwind')
@section('title', __('Dashboard'))
@section('breadcrumb_section', 'Overview')
@section('breadcrumb_page', __('Dashboard'))
@php
$adminUser = Auth::guard('admin')->user();
$hour = now()->hour;
$greeting = $hour < 12 ? 'Good morning' : ($hour < 17 ? 'Good afternoon' : 'Good evening');
$totalUsers = $total_freelancer + $total_client;
// Sparkline path generator — returns SVG path string from oldest→newest values
$sfn = function(array $data, $w = 120, $h = 36) {
$vals = array_values($data);
if (count($vals) < 2) return 'M0 ' . ($h - 3) . ' L' . $w . ' ' . ($h - 3);
$min = min($vals); $max = max($vals);
$range = max($max - $min, 1);
$n = count($vals);
$pts = [];
foreach ($vals as $i => $v) {
$x = round(($i / ($n - 1)) * $w, 2);
$y = round($h - (($v - $min) / $range) * ($h - 6) - 3, 2);
$pts[] = $x . ' ' . $y;
}
return 'M' . implode(' L', $pts);
};
// Sort each monthly array oldest→newest (key 11=oldest, key 0=newest → krsort descending)
krsort($monthly_income); $revData = array_values($monthly_income);
krsort($monthly_users); $usrData = array_values($monthly_users);
krsort($monthly_orders_spark); $ordData = array_values($monthly_orders_spark);
krsort($monthly_jobs_spark); $jobData = array_values($monthly_jobs_spark);
$pendingActions = [];
if (moduleExists('Wallet')) {
$pendingActions[] = [
'priority' => 'high',
'label' => 'danger',
'count' => $pending_withdraw_count,
'title' => __('Pending Withdrawals'),
'sub' => __('awaiting admin review'),
'route' => route('admin.wallet.withdraw.request'),
'can' => 'withdraw-list',
];
$pendingActions[] = [
'priority' => 'high',
'label' => 'warn',
'count' => $pending_deposit_count,
'title' => __('Pending Deposits'),
'sub' => __('awaiting confirmation'),
'route' => route('admin.wallet.history'),
'can' => 'deposit-list',
];
}
$pendingActions[] = [
'priority' => 'med',
'label' => 'info',
'count' => $identity_verify_count,
'title' => __('Identity Verify Requests'),
'sub' => __('submitted, needs review'),
'route' => route('admin.user.verification.request'),
'can' => 'user-identity-verify-request-list',
];
$pendingActions[] = [
'priority' => 'med',
'label' => 'warn',
'count' => $user_report_count,
'title' => __('User Reports / Disputes'),
'sub' => __('filed by users'),
'route' => route('admin.user.report.all'),
'can' => null,
];
@endphp
@section('content')
{{-- Page head --}}
{{ $greeting }}, {{ $adminUser->name ?? 'Admin' }}
{{ now()->format('l, F j') }}
@if(moduleExists('Wallet') && $pending_withdraw_count + $pending_deposit_count > 0)
· {{ $pending_withdraw_count + $pending_deposit_count }} {{ __('payment actions pending') }}
@endif
{{ __('All Orders') }}
@if(moduleExists('Wallet'))
@can('withdraw-list')
{{ __('Payout Queue') }}
@endcan
@endif
{{-- KPI tiles --}}
{{ __('Total Revenue') }}
{{ float_amount_with_currency_symbol($total_revenue ?? 0) }}
{{ __('Orders') }}: {{ float_amount_with_currency_symbol($total_order_revenue ?? 0) }}
{{ number_format($totalUsers) }}
{{ number_format($total_freelancer) }} {{ __('freelancers') }} · {{ number_format($total_client) }} {{ __('clients') }}
{{ number_format($total_job) }}
{{ number_format($total_orders) }}
{{-- Main two-column row --}}
{{-- Pending Actions --}}
{{ __('Pending Actions') }}
@php $totalPending = (moduleExists('Wallet') ? $pending_withdraw_count + $pending_deposit_count : 0) + $identity_verify_count + $user_report_count; @endphp
@if($totalPending > 0)
{{ $totalPending }} {{ __('items') }}
@else
{{ __('All clear') }}
@endif
{{-- Recent Orders --}}
@forelse($orders as $order)
{{ mb_strtoupper(mb_substr($order->user->name ?? 'U', 0, 2)) }}
{{ Str::limit($order->user->name ?? __('User'), 18) }}
{{ float_amount_with_currency_symbol($order->price ?? 0) }} · {{ ucfirst($order->is_project_job ?? '') }}
@if($order->payment_status === 'complete')
{{ __('Paid') }}
@elseif($order->payment_status === 'pending')
{{ __('Pending') }}
@else
{{ ucfirst($order->payment_status ?? '') }}
@endif
{{ $order->created_at ? $order->created_at->diffForHumans(null, true, true) : '' }}
@empty
{{ __('No orders yet') }}
@endforelse
{{-- Bottom row --}}
{{-- Withdraw Queue --}}
@if(moduleExists('Wallet'))
{{ __('Withdraw Queue') }}
{{ float_amount_with_currency_symbol($pending_withdraw_amount ?? 0) }}
@if($pending_withdraw_count > 0)
{{ $pending_withdraw_count }} {{ __('pending') }}
@else
{{ __('All settled') }}
@endif
@endif
{{-- Platform Settings --}}
@php
$platformSettings = [
__('Commission Type') => ucfirst(get_static_option('admin_commission_type') ?? '—'),
__('Commission Charge') => get_static_option('admin_commission_charge') ?? '0',
__('Transaction Fee Type') => ucfirst(get_static_option('transaction_fee_type') ?? '—'),
__('Transaction Fee') => get_static_option('transaction_fee_charge') ?? '0',
__('Job Auto Approval') => ucfirst(get_static_option('job_auto_approval') ?? '—'),
__('Project Auto Approval') => ucfirst(get_static_option('project_auto_approval') ?? '—'),
];
@endphp
@foreach($platformSettings as $label => $value)
@endforeach
{{-- Top Freelancers --}}
@php $maxEarned = $top_freelancers->max('total_earned') ?: 1; @endphp
@forelse($top_freelancers as $i => $fl)
{{ mb_strtoupper(mb_substr($fl->first_name ?? 'F', 0, 1) . mb_substr($fl->last_name ?? '', 0, 1)) }}
{{ Str::limit($fl->fullname ?? '—', 16) }}
{{ $fl->completed_orders }} {{ __('jobs') }}
{{ float_amount_with_currency_symbol($fl->total_earned ?? 0) }}
@empty
{{ __('No completed orders yet') }}
@endforelse
@endsection