@forelse($offers as $offer) @php $compactSeller = $compactSeller ?? false; $currency = $offer->wallet->currency->code; $assetKey = strtolower($currency); $currencyFlag = $offer->wallet->currency->flag ?? null; $isSelf = (int) $offer->user_id === (int) auth()->id(); $user = $offer->user; $userName = $offer->user?->name ?? __('User'); $initials = strtoupper(substr((string) $offer->user?->first_name, 0, 1) . substr((string) $offer->user?->last_name, 0, 1)); $initials = $initials !== '' ? $initials : strtoupper(substr((string) $userName, 0, 1)); $isBuy = $offer->side === \App\Enums\P2P\OrderSide::SELL; $btnLabel = ($isBuy ? __('Buy') : __('Sell')) . ' ' . $currency; $btnIcon = $isBuy ? 'fa-shopping-cart' : 'fa-tag'; $actionModifier = $isBuy ? 'p2p-offer-action-btn--buy' : 'p2p-offer-action-btn--sell'; $assetModifier = $isBuy ? match ($assetKey) { 'btc' => 'p2p-offer-action-btn--asset-btc', 'eth' => 'p2p-offer-action-btn--asset-eth', default => '', } : ''; $decimals = (int) setting('site_decimal', 2); $stats = $sellerStats[(int) $offer->user_id] ?? null; $completedOrders = (int) ($stats['completed_orders'] ?? 0); $totalOrders = (int) ($stats['total_orders'] ?? 0); $completionRate = (float) ($stats['completion_rate'] ?? 0); $avgRating = $stats['avg_rating'] ?? null; $positiveFeedback = (int) ($stats['positive_feedback'] ?? 0); $isVerified = $user ? $user->isKycVerified() : false; $isTrusted = $totalOrders >= 10 && $completionRate >= 95 && (($avgRating !== null && $avgRating >= 4.5) || $positiveFeedback >= 10); $isHighVolume = $completedOrders >= 50; $fiatCurrency = (string) setting('site_currency', ''); $fiatCurrency = $fiatCurrency !== '' ? $fiatCurrency : $currency; $availableText = $offer->max_amount !== null ? number_format((float) $offer->max_amount, $decimals) : __('Unlimited'); $limitText = number_format((float) $offer->min_amount, $decimals) . ' - ' . ($offer->max_amount !== null ? number_format((float) $offer->max_amount, $decimals) : __('Unlimited')); $hasActiveOrders = (int) ($offer->active_orders_count ?? 0) > 0; $selfActionLabel = __('Manage Ad'); $promotion = $offer->promotion; $isSponsored = $promotion && $promotion->status === \App\Enums\P2P\PromotionStatus::ACTIVE && $promotion->ends_at && $promotion->ends_at->isFuture(); $promotionFeatures = (array) ($promotion?->package?->features ?? []); $hasHighlightedCard = $isSponsored && !empty($promotionFeatures['highlighted_card']); $hasFeaturedBadge = $isSponsored && (!empty($promotionFeatures['featured_badge']) || !empty($promotionFeatures['verified_badge'])); $accentColor = strtoupper(trim((string) ($promotion?->package?->accent_color ?? ''))); $hasAccentColor = in_array($accentColor, ['GOLD', 'BLUE', 'RED'], true); $accentCardClass = $hasAccentColor ? match ($accentColor) { 'GOLD' => 'p2p-offer-card--accent-gold', 'RED' => 'p2p-offer-card--accent-red', default => 'p2p-offer-card--accent-blue', } : ''; $hasSoftAccentBorder = $isSponsored && !$hasHighlightedCard && $hasAccentColor; $cardClass = implode(' ', array_filter([ 'p2p-offer-card', $compactSeller ? 'p2p-offer-card--profile' : null, $isSponsored ? 'p2p-offer-card--sponsored' : null, $hasHighlightedCard ? 'p2p-offer-card--highlighted' : null, $hasSoftAccentBorder ? 'p2p-offer-card--accent-soft' : null, $accentCardClass, ])); @endphp
@if($compactSeller)
{{ $offer->side->label() }}
{{ $btnLabel }} {{ (int) ($offer->payment_window_minutes ?? 0) }} @lang('min')
@else
@if($user && ! empty($user->avatar))
{{ $userName }}
@else
{{ $initials }}
@endif
@if($isVerified) @lang('Verified') @endif
{{ number_format($completionRate, 1) }}% @lang('completion') | {{ number_format($totalOrders) }} @lang('trades')
@endif
@unless($compactSeller) @lang('Available'): @endunless {{ $availableText }} {{ $currency }}
@if(! $compactSeller && $isTrusted) @lang('Trusted') @endif @if(! $compactSeller && $isHighVolume) @lang('High Volume') @endif @if($isSponsored) @lang('Promoted') @if($hasFeaturedBadge) @lang('Featured') @endif @endif
@php $pmMethods = $offer->paymentMethods->filter(fn ($m) => !empty($m?->name))->values(); $pmNames = $pmMethods->pluck('name')->filter()->values(); $pmAll = $pmNames->implode(', '); $pmJson = $pmMethods->map(function ($m) { return [ 'id' => (int) $m->id, 'name' => (string) $m->name, 'logo' => !empty($m->logo) ? asset('storage/'.$m->logo) : null, 'instructions' => (string) ($m->instructions ?? ''), ]; })->values(); $advertiserUrl = route('user.p2p.advertisers.show', $offer->user_id); $paymentPreviewCount = $compactSeller ? 2 : 3; @endphp
@if(!empty($currencyFlag)) @else {{ strtoupper(substr($currency, 0, 1)) }} @endif {{ $currency }} -> {{ number_format((float) $offer->price, $decimals) }} {{ $fiatCurrency }} @lang('per') {{ $currency }}
@if($compactSeller)
@lang('Range') {{ $limitText }} {{ $currency }}
@lang('Methods') @if($pmNames->isNotEmpty()) @foreach($pmMethods->take($paymentPreviewCount) as $pm) @if(! empty($pm->logo)) @else @endif {{ $pm->name }} @endforeach @if($pmNames->count() > $paymentPreviewCount) +{{ $pmNames->count() - $paymentPreviewCount }} @endif @else @lang('No payment methods') @endif
@else
@lang('Limit'): {{ $limitText }} {{ $currency }}
@lang('Payment'): @if($pmNames->isNotEmpty()) @foreach($pmMethods->take($paymentPreviewCount) as $pm) @if(! empty($pm->logo)) @else @endif {{ $pm->name }} @endforeach @if($pmNames->count() > $paymentPreviewCount) +{{ $pmNames->count() - $paymentPreviewCount }} @endif @else @lang('No payment methods') @endif
@endif
@if($isSelf) {{ $selfActionLabel }} @if($hasActiveOrders)
@lang('Active order running')
@elseif(! $compactSeller)
@lang('Manage tools')
@endif @else @endif @if(! $compactSeller)
@lang('Est. time'): ~{{ (int) ($offer->payment_window_minutes ?? 0) }} @lang('min')
@endif
@empty @endforelse