@php use App\Enums\TrxType; @endphp @extends('frontend.layouts.user.index') @section('title', __('My Wallet Earn Stakes')) @push('styles') @endpush @section('content')
{{ __('Earn Plans') }} {{ __('Reward History') }}
{{-- Summary Cards --}}
{{ __('Active Positions') }}
{{ $metrics['active_count'] }}
{{ $metrics['pending_count'] }} {{ __('pending') }}
{{ __('Total Earned') }}
{{ number_format((float) $metrics['rewards_paid'], (int) setting('site_decimal', 2)) }}
{{ __('Across all plans') }}
{{ __('Next Payout') }}
@if($metrics['next_payout_at']) {{ \Carbon\Carbon::parse($metrics['next_payout_at'])->format('d M Y') }} @else — @endif
{{ __('Nearest upcoming') }}
{{ __('Total Positions') }}
{{ $metrics['total_count'] }}
{{ $metrics['completed_count'] }} {{ __('completed') }}
{{-- Tabs --}} {{-- Stakes Grid --}}
@forelse($stakes as $i => $stake) @php $dec = (int) setting('site_decimal', 2); $totalDays = ($stake->starts_at && $stake->matures_at) ? max(1, $stake->starts_at->diffInDays($stake->matures_at)) : 1; $doneDays = $stake->starts_at ? min($totalDays, max(0, $stake->starts_at->diffInDays(now()))) : 0; $pct = $stake->status->isTerminal() ? 100 : min(100, max(0, (int) round(($doneDays / $totalDays) * 100))); $daysLeft = ($stake->matures_at && $stake->isActive()) ? max(0, (int) now()->diffInDays($stake->matures_at, false)) : 0; $isFeatured = ((bool) ($stake->plan->is_featured ?? false)) && $stake->isActive(); $walletName = $stake->currency->code . ' ' . __('Wallet'); $statusVal = $stake->status->value; $rateDisplay = $stake->profit_type === \App\Enums\WalletEarnProfitType::Percentage ? number_format((float) $stake->profit_rate, 2) . '%' : number_format((float) $stake->profit_rate, $dec) . ' ' . $stake->currency->code; $stakeData = json_encode([ 'id' => $stake->id, 'plan_name' => $stake->plan_name, 'wallet_name' => $walletName, 'status' => $statusVal, 'status_label' => $stake->status->label(), 'amount' => number_format($stake->principal_amount, $dec), 'currency' => $stake->currency->code, 'rate' => $stake->profit_rate, 'rate_display' => $rateDisplay, 'starts_at' => $stake->starts_at?->format('d M Y') ?? __('Pending'), 'matures_at' => $stake->matures_at?->format('d M Y') ?? __('Pending'), 'next_payout' => $stake->next_payout_at?->format('d M Y, h:i A') ?? __('Not scheduled'), 'payout_freq' => $stake->payout_frequency->label(), 'paid_profit' => number_format((float) $stake->paid_profit, $dec), 'exp_profit' => number_format((float) $stake->expected_profit, $dec), 'total_return' => number_format($stake->principal_amount + $stake->paid_profit, $dec), 'payouts_made' => $stake->payouts_made, 'total_payouts' => $stake->total_payouts, 'pct' => $pct, 'days_left' => $daysLeft, 'is_featured' => $isFeatured, 'show_url' => route('user.wallet-earn.show', $stake), 'is_pending' => $stake->status->value === 'pending', 'is_active' => $stake->isActive(), 'is_terminal' => $stake->status->isTerminal(), 'rewards' => $stake->rewards->map(fn ($r) => [ 'label' => __('Payout') . ' #' . $r->payout_number, 'amount' => number_format((float) $r->amount, $dec), 'date' => $r->paid_at?->format('d M Y') ?? $r->created_at->format('d M Y'), ])->values()->all(), ]); @endphp
{{-- Top row --}}
{{ $stake->plan_name }}
{{ $walletName }}
{{ $stake->status->label() }}
{{-- Amount + reward rate --}}
{{ number_format($stake->principal_amount, $dec) }} {{ $stake->currency->code }} @ {{ $rateDisplay }} {{ __('per payout') }}
{{-- Dates --}}
{{ __('Start') }}: {{ $stake->starts_at?->format('d M Y') ?? __('Pending') }}
{{ __('Matures') }}: {{ $stake->matures_at?->format('d M Y') ?? __('Pending') }}
{{-- Progress bar --}} @if($stake->starts_at)
{{ __('Maturity') }} {{ $pct }}%{{ $stake->isActive() && $daysLeft > 0 ? ' · ' . $daysLeft . 'd ' . __('left') : '' }}
@endif {{-- Footer --}}
@empty @endforelse
{{-- Pagination --}} @if($stakes->hasPages())
{{ $stakes->links() }}
@endif
{{-- Bottom Sheet Drawer --}} {{-- /#weStakeSheet --}} @endsection @push('scripts') @endpush