@php use App\Enums\AgentStatus; use App\Enums\AmountFlow; use App\Enums\KycStatus; use App\Enums\TrxType; use App\Services\WalletService; use Illuminate\Support\Facades\Route; $dashboardUser = auth()->user(); $wallets = $dashboardUser ? ($dashboardUser->activeWallets() ?? collect()) : collect(); $walletService = app(WalletService::class); $mobileWalletCounterCashOutRoute = route('user.agent.index', ['tab' => 'counter-cashout']); if ($dashboardUser?->isAgent()) { $mobileWalletCounterCashOutAgent = $dashboardUser->agent() ->where('status', AgentStatus::APPROVED) ->where('qr_enabled', true) ->whereNotNull('qr_token') ->latest() ->first(); $mobileWalletCounterCashOutRoute = $mobileWalletCounterCashOutAgent?->qrCashOutUrl() ?? $mobileWalletCounterCashOutRoute; } $mobileWalletProfile = match (true) { $dashboardUser?->isMerchant() => [ 'role' => 'merchant', 'label' => __('Merchant Wallet'), 'primary_label' => __('Add Funds'), 'primary_icon' => 'fa-plus', 'primary_route' => route('user.deposit.create'), 'secondary_label' => __('Shops'), 'secondary_icon' => 'fa-store', 'secondary_route' => route('user.merchant.index'), ], $dashboardUser?->isAgent() => [ 'role' => 'agent', 'label' => __('Agent Wallet'), 'primary_label' => __('Cash-In'), 'primary_icon' => 'fa-wallet', 'primary_route' => route('user.agent.index', ['tab' => 'cash-in']), 'secondary_label' => __('Counter Cash-Out'), 'secondary_icon' => 'fa-money-bill-wave', 'secondary_route' => $mobileWalletCounterCashOutRoute, ], default => [ 'role' => 'user', 'label' => __('Personal Wallet'), 'primary_label' => __('Deposit'), 'primary_icon' => 'fa-plus', 'primary_route' => route('user.deposit.create'), 'secondary_label' => __('My Wallets'), 'secondary_icon' => 'fa-sliders', 'secondary_route' => route('user.wallet.index'), ], }; // KYC slim banner state $kyc = $dashboardUser?->kycSubmission; $kycStatus = $kyc?->status ?? null; $kycShow = !$dashboardUser?->isKycVerified() && (isActive('user.settings.kyc.verify') !== 'active'); $kycState = 'missing'; $kycTitle = __('Verify your identity'); $kycSub = __('Submit your details and documents to unlock wallet features.'); $kycCta = __('Start verification'); $kycIcon = 'fa-id-card'; if ($kycStatus === KycStatus::PENDING) { $kycState = 'pending'; $kycTitle = __('Identity review in progress'); $kycSub = __('Reviews usually finish within 24 hours.'); $kycCta = __('Check status'); $kycIcon = 'fa-hourglass-half'; } elseif ($kycStatus === KycStatus::REJECTED) { $kycState = 'rejected'; $kycTitle = __('Update your KYC details'); $kycSub = __('Review the notes and resubmit your documents.'); $kycCta = __('Resubmit KYC'); $kycIcon = 'fa-triangle-exclamation'; } $featureManager = app(\App\Services\FeatureManager::class); $actionHub = match (true) { $dashboardUser?->isMerchant() => [ 'title' => __('Merchant actions'), 'badge' => __('Merchant'), 'items' => [ ['label' => __('Create Link'), 'meta' => __('Get paid'), 'route' => 'user.payment-links.create', 'icon' => 'payment-link', 'tone' => 'primary', 'feature' => 'payment_link'], ['label' => __('Merchant'), 'meta' => __('Shops'), 'route' => 'user.merchant.index', 'icon' => 'merchant', 'tone' => 'merchant'], ['label' => __('Sales'), 'meta' => __('Payments'), 'route' => 'user.transaction.index', 'params' => ['type' => 'receive_payment'], 'icon' => 'receive-payment-1', 'tone' => 'success'], ['label' => __('Links'), 'meta' => __('Manage'), 'route' => 'user.payment-links.index', 'icon' => 'payment-link', 'tone' => 'primary', 'feature' => 'payment_link'], ], ], $dashboardUser?->isAgent() => [ 'title' => __('Agent actions'), 'badge' => __('Agent'), 'items' => [ ['label' => __('Cash In'), 'meta' => __('Top-up'), 'route' => 'user.agent.index', 'params' => ['tab' => 'cash-in'], 'icon' => 'receive-money', 'tone' => 'primary', 'feature' => 'agent_program'], ['label' => __('Cash Out'), 'meta' => __('Counter'), 'route' => 'user.agent.index', 'params' => ['tab' => 'counter-cashout'], 'icon' => 'qrcode', 'tone' => 'agent', 'feature' => 'agent_program'], ['label' => __('Queue'), 'meta' => __('Requests'), 'route' => 'user.agent.index', 'params' => ['tab' => 'cash-out-requests'], 'icon' => 'request-list', 'tone' => 'warning', 'feature' => 'agent_program'], ['label' => __('Wallet'), 'meta' => __('Balances'), 'route' => 'user.wallet.index', 'icon' => 'wallet', 'tone' => 'primary'], ], ], default => [ 'title' => __('Wallet actions'), 'badge' => __('Wallet'), 'items' => [ ['label' => __('Deposit'), 'meta' => __('Add funds'), 'route' => 'user.deposit.create', 'icon' => 'deposit', 'tone' => 'success', 'feature' => 'deposit_money'], ['label' => __('Withdraw'), 'meta' => __('Cash out'), 'route' => 'user.withdraw.create', 'icon' => 'withdraw', 'tone' => 'danger', 'feature' => 'withdraw_money'], ['label' => __('Send'), 'meta' => __('Transfer'), 'route' => 'user.send-money.create', 'icon' => 'send-money', 'tone' => 'primary', 'feature' => 'send_money'], ['label' => __('Receive'), 'meta' => __('QR code'), 'route' => 'user.wallet.my-qr-code', 'icon' => 'qrcode', 'tone' => 'primary'], ], ], }; $secondaryActionItems = [ ['label' => __('Request'), 'route' => 'user.request-money.create', 'icon' => 'request-money', 'tone' => 'warning', 'feature' => 'request_money'], ['label' => __('Exchange'), 'route' => 'user.exchange-money.create', 'icon' => 'exchange', 'tone' => 'violet', 'feature' => 'exchange_money'], ['label' => __('Cards'), 'route' => 'user.virtual-card.index', 'icon' => 'virtual-card', 'tone' => 'success', 'feature' => 'virtual_card'], ['label' => __('Recharge'), 'route' => 'user.mobile-recharge.create', 'icon' => 'mobile-recharge', 'tone' => 'primary', 'feature' => 'mobile_recharge'], ['label' => __('Voucher'), 'route' => 'user.voucher.my', 'icon' => 'voucher', 'tone' => 'warning', 'feature' => 'vouchers'], ]; if ($dashboardUser?->isMerchant()) { array_unshift( $secondaryActionItems, ['label' => __('Payment Links'), 'route' => 'user.payment-links.index', 'icon' => 'payment-link', 'tone' => 'primary', 'feature' => 'payment_link'] ); } if ($dashboardUser?->isAgent()) { array_unshift( $secondaryActionItems, ['label' => __('Wallet'), 'route' => 'user.wallet.index', 'icon' => 'wallet', 'tone' => 'primary'] ); } if (Route::has('user.p2p.offers.index') && setting('p2p_enabled') && $featureManager->isVisible('p2p_marketplace')) { $secondaryActionItems[] = [ 'label' => __('P2P'), 'route' => 'user.p2p.offers.index', 'icon' => 'p2p_trading', 'tone' => 'primary', 'feature' => 'p2p_marketplace', ]; } if (Route::has('user.marketplace.index') && (bool) (\App\Models\MarketplaceSetting::current()?->enabled)) { $secondaryActionItems[] = [ 'label' => __('Payment'), 'route' => 'user.marketplace.index', 'icon' => 'merchant', 'tone' => 'success', 'feature' => 'vendor_marketplace', ]; } $secondaryActionItems[] = ['label' => __('Support'), 'route' => 'user.support-ticket.index', 'icon' => 'support', 'tone' => 'primary']; $secondaryActionItems[] = ['label' => __('Security'), 'route' => 'user.settings.security.index', 'icon' => 'security', 'tone' => 'slate']; $isActionVisible = static fn (array $item): bool => Route::has($item['route']) && (! isset($item['feature']) || $featureManager->isVisible($item['feature'])); $actionKey = static fn (array $item): string => $item['route'].'|'.http_build_query($item['params'] ?? []); $priorityActionItems = collect($actionHub['items']) ->filter($isActionVisible) ->unique($actionKey) ->values() ->all(); $priorityActionKeys = collect($priorityActionItems)->map($actionKey)->all(); $secondaryActionItems = collect($secondaryActionItems) ->filter($isActionVisible) ->reject(fn (array $item): bool => in_array($actionKey($item), $priorityActionKeys, true)) ->unique($actionKey) ->take(7) ->values() ->all(); $snapshotCardTones = ['mint', 'azure', 'rose', 'amber', 'violet']; $excludedSnapshotTitles = [ TrxType::DEPOSIT->label(), TrxType::WITHDRAW->label(), ]; $snapshotPriority = match (true) { $dashboardUser?->isMerchant() => [ TrxType::RECEIVE_PAYMENT->label(), __('Merchant Shop'), __('Awaiting Merchant'), TrxType::REQUEST_MONEY->label(), TrxType::RECEIVE_MONEY->label(), ], $dashboardUser?->isAgent() => [ TrxType::RECEIVE_MONEY->label(), TrxType::SEND_MONEY->label(), TrxType::EXCHANGE_MONEY->label(), __('Total Tickets'), __('Total Referrals'), ], default => [ TrxType::SEND_MONEY->label(), TrxType::REQUEST_MONEY->label(), TrxType::EXCHANGE_MONEY->label(), TrxType::RECEIVE_MONEY->label(), __('Total Referrals'), ], }; $mobileSnapshotStats = collect($statistics ?? []) ->reject(fn (array $statistic): bool => in_array((string) $statistic['title'], $excludedSnapshotTitles, true)) ->sortBy(function (array $statistic) use ($snapshotPriority): int { $priority = array_search((string) $statistic['title'], $snapshotPriority, true); return $priority === false ? 99 : $priority; }) ->take(5) ->values() ->all(); // Group transactions $today = now()->startOfDay(); $yesterday = $today->copy()->subDay(); $weekStart = $today->copy()->subDays(6); $mobileGroups = [ __('Today') => collect(), __('Yesterday') => collect(), __('This week') => collect(), __('Earlier') => collect(), ]; foreach (($transactions ?? collect()) as $tx) { $d = $tx->created_at->copy()->startOfDay(); if ($d->equalTo($today)) $mobileGroups[__('Today')]->push($tx); elseif ($d->equalTo($yesterday)) $mobileGroups[__('Yesterday')]->push($tx); elseif ($d->greaterThanOrEqualTo($weekStart)) $mobileGroups[__('This week')]->push($tx); else $mobileGroups[__('Earlier')]->push($tx); } $toneFor = function ($tx) { $status = $tx->status->value ?? ''; if (in_array($status, ['failed', 'rejected', 'cancelled'])) return 'neutral'; $flow = $tx->amount_flow ?? null; if ($flow === AmountFlow::PLUS) return 'in'; if ($flow === AmountFlow::MINUS) return 'out'; $type = $tx->trx_type->value ?? ''; if (str_contains($type, 'exchange') || str_contains($type, 'p2p')) return 'swap'; return 'neutral'; }; $dirFor = function ($tx) { $status = $tx->status->value ?? ''; if (in_array($status, ['failed', 'rejected', 'cancelled'])) return 'failed'; $flow = $tx->amount_flow ?? null; if ($flow === AmountFlow::PLUS) return 'in'; return 'out'; }; @endphp {{-- ========================================================== | DigiKash Mobile App Dashboard | Visible only at < 992px (Bootstrap d-lg-none). ========================================================== --}}
{{-- Hero wallet carousel --}}
@forelse($wallets as $wallet) @php $maskedUuid = $walletService->formatMaskedWalletId($wallet->uuid); @endphp @empty
{{ __('Wallet') }} {{ siteCurrency() }}0.00
@endforelse
@if(count($wallets) > 1)
@foreach($wallets as $i => $wallet) @endforeach
@else
@endif
{{-- KYC slim banner --}} @if($kycShow)
{{ $kycTitle }}
{{ $kycSub }}
{{ $kycCta }}
@endif {{-- Role-aware action hub --}}

{{ $actionHub['title'] }}

{{ __('All') }}
@if($priorityActionItems !== [])
@foreach($priorityActionItems as $item) {{ $item['label'] }} {{ $item['meta'] }} @endforeach
@endif
@if($secondaryActionItems !== [])
{{ __('Quick actions') }}
@foreach($secondaryActionItems as $item) {{ $item['label'] }} @endforeach
@endif {{-- Snapshot rail --}} @if($mobileSnapshotStats !== [])

{{ __('Snapshot') }}

{{ __('Stats') }}
@foreach($mobileSnapshotStats as $i => $statistic)
{{ $statistic['title'] }}
{{ $statistic['value'] }}
@if(isset($statistic['link'])) @endif
@endforeach
@endif {{-- Insights segmented chart --}} @if(isset($totalSuccessDeposit) || isset($totalSuccessWithdraw))
{{ __('Last 7d') }}
{{ $totalSuccessDeposit ?? '' }}
{{ __('Total Deposited') }}
@endif {{-- Recent transactions grouped --}}

{{ __('Recent activity') }}

{{ __('View all') }}
@if(($transactions ?? collect())->isEmpty()) @else @foreach($mobileGroups as $label => $group) @if($group->isNotEmpty())
{{ $label }}
@foreach($group as $transaction) @php $tone = $toneFor($transaction); $dir = $dirFor($transaction); $statusValue = $transaction->status->value ?? ''; $transactionTypeClass = $transaction->trx_type->kebabCase(); $amountSign = $transaction->amount_flow->sign($transaction->status); $icon = $transaction->trx_type->icon(); @endphp @endforeach
@endif @endforeach @endif
{{-- ========================================================== | Mobile insight chart bootstrap (ApexCharts is already loaded) ========================================================== --}} @push('scripts') @endpush