@extends('layout') @section('content')

💰 My Wallet

Manage your coins and balance

💎 Total Coins
{{ $wallet ? $wallet->coins : 0 }}
💵 Rupiah Value
Rp {{ number_format(($wallet ? $wallet->coins : 0) * 1000, 0, ',', '.') }}
👤 User
{{ auth()->user()->name }}
🏷️ Role
{{ ucfirst(auth()->user()->role) }}
🎁 Tambah Coin via Qris / Permintaan Pencairan Via Rekening
@php $isTalent = (!empty(auth()->user()->is_talent) || (auth()->user()->role ?? '') === 'talent'); $isAdminKota = (auth()->user()->role ?? '') === 'admin_kota'; $canWithdraw = $isTalent || $isAdminKota; @endphp
@if(!$isTalent && !$isAdminKota)
📌 1 Coin = Rp 1.000
@endif @if($canWithdraw)
📌 1 Coin = Rp 1.000 @if(auth()->user()->bank_account_number) 💳 Bank: {{ auth()->user()->bank_name ?? '-' }} | Akun: ***{{ substr(auth()->user()->bank_account_number, -4) }} @else @endif
@endif
📊 History Transaksi
@if($transactions->count() == 0)

Belum ada transaksi

@else
@foreach($transactions as $t) @php // Get QRIS transaction details if available $qris = $t->qrisTransaction; // Try to determine payment method from multiple sources $method = $t->payment_method ?? null; // Priority 1: QRIS transaction data if ($qris && $qris->payment_method) { $method = $qris->payment_method; } // Priority 2: Transaction payload if (!$method && !empty($t->payload)) { $pl = json_decode($t->payload, true); if (is_array($pl)) { $method = $pl['payment_method'] ?? $pl['method'] ?? null; } } // Priority 3: Parse from description if (!$method && !empty($t->description)) { if (preg_match('/\(([^)]+)\)/', $t->description, $m)) { $method = $m[1]; } } // Normalize if ($method) { $method = preg_replace('/^duitku_/i', '', $method); $method = strtoupper($method); } @endphp
status === 'pending' && $t->type === 'credit') onclick="reopenPaymentModal({{ $t->id }}, {{ $t->amount * 1000 }}, '{{ $method ?? 'UNKNOWN' }}', '{{ base64_encode($t->payload ?? '{}') }}');" style="cursor: pointer; transition: all 0.3s;" onmouseover="this.style.opacity='1'; this.style.backgroundColor='#f8f9fa';" onmouseout="this.style.opacity='0.85'; this.style.backgroundColor='transparent';" @endif data-tx-id="{{ $t->id }}" data-tx-amount="{{ $t->amount * 1000 }}" data-tx-status="{{ $t->status }}" data-tx-type="{{ $t->type }}" @if($qris)data-qris-id="{{ $qris->id }}"@endif>
{{ str_replace(['Deposit', 'Withdraw to bank'], ['Tambah Coin', 'Permintaan Pencairan ke Rekening'], $t->description) }} @if($t->type === 'credit' && !empty($method)) {{ strtoupper($method) }} @endif
{{ $t->created_at->format('d M Y H:i') }} @if($qris) Ref: {{ $qris->reference_no }} @endif
{{ $t->type === 'credit' ? '+' : '-' }}{{ $t->amount }} Coins
{{ ucfirst($t->status) }} {{ $t->status === 'pending' && $t->type === 'credit' ? '(klik untuk lihat)' : '' }}
@endforeach
@php $isPaginator = $transactions instanceof \Illuminate\Pagination\LengthAwarePaginator; $total = $isPaginator ? $transactions->total() : ($transactions->count() ?? 0); @endphp @if($isPaginator && $total > 0)
Menampilkan {{ (($transactions->currentPage() - 1) * $transactions->perPage()) + 1 }} - {{ min($transactions->currentPage() * $transactions->perPage(), $total) }} dari {{ $total }} transaksi
@endif @endif
@endsection