@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