@extends('backend.p2p.layout') @section('title', __('P2P Traders')) @section('p2p_title') {{ __('Traders') }} @endsection @section('p2p_icon', 'badge-account') @php $traderTotal = method_exists($users, 'total') ? (int) $users->total() : $users->count(); $items = collect($users->items() ?? $users); $verifiedCount = $items->filter(fn ($u) => $u->isKycVerified())->count(); $suspendedCount = $items->filter(fn ($u) => $u->isP2pTradingSuspended())->count(); $tierFor = function (int $totalOrders): array { return match (true) { $totalOrders >= 1000 => ['merchant', __('Merchant')], $totalOrders >= 250 => ['gold', __('Gold')], $totalOrders >= 50 => ['silver', __('Silver')], default => ['bronze', __('Bronze')], }; }; $toneFor = function (string $seed): string { $tones = ['blue', 'green', 'amber', 'rose', 'violet', 'teal']; return $tones[abs(crc32($seed)) % count($tones)]; }; @endphp @section('p2p_action')
@endsection @section('p2p_content') @php $hasTraders = $traderTotal > 0; $hasSearch = ! empty($search); @endphp
@lang('Directory')
@lang('Trader directory')
@if($hasTraders)
{{ number_format($traderTotal) }} {{ trans_choice('trader|traders', $traderTotal) }} @if($verifiedCount > 0) {{ number_format($verifiedCount) }} @lang('verified') @endif @if($suspendedCount > 0) {{ number_format($suspendedCount) }} @lang('suspended') @endif
@endif
@if($hasTraders)
@if($verifiedCount > 0) @endif @if($suspendedCount > 0) @endif
@if($users->lastPage() > 1)
@lang('Page :n of :t', ['n' => $users->currentPage(), 't' => $users->lastPage()]) @endif
@endif @if(! $hasTraders) @else
@foreach($users as $u) @php $s = $stats[(int) $u->id] ?? []; $isSuspended = $u->isP2pTradingSuspended(); $kycOk = $u->isKycVerified(); $totalOrders = (int) ($s['total_orders'] ?? 0); $completion = (float) ($s['completion_rate'] ?? 0); $progressTone = $completion >= 90 ? '' : ($completion >= 70 ? 'fb-progress__fill--warn' : 'fb-progress__fill--low'); $initials = strtoupper(substr((string) $u->first_name, 0, 1).substr((string) $u->last_name, 0, 1)); $initials = $initials !== '' ? $initials : strtoupper(substr((string) ($u->name ?? '?'), 0, 1)); [$tierKey, $tierLabel] = $tierFor($totalOrders); $tone = $toneFor((string) ($u->username ?? $u->email ?? $u->id)); @endphp @endforeach
@lang('Trader') @lang('Tier') @lang('KYC') @lang('Ads') @lang('Orders') @lang('Completion') @lang('Rating') @lang('Action')
@if(!empty($u->avatar)) {{ $u->name }} @else {{ $initials }} @endif {{ $u->name }} {{ $u->username ? '@'.$u->username : $u->email }}
{{ $tierLabel }} @if($isSuspended) @lang('Suspended') @elseif($kycOk) @lang('Verified') @else @lang('Pending') @endif {{ number_format((int) ($s['offers_count'] ?? 0)) }} {{ number_format($totalOrders) }} @lang('completion') {{ number_format($completion, 1) }}% @if(($s['avg_rating'] ?? null) !== null) {{ number_format((float) $s['avg_rating'], 1) }} ({{ number_format((int) ($s['feedback_count'] ?? 0)) }}) @else — @endif
@if($users->hasPages()) @endif @endif
@endsection