{{-- TradeIndia-style Product Card --}} @php $seller = $product->seller; $plan = $seller->plan; $hasSubscription = $seller->hasActiveSubscription(); $showContact = $hasSubscription && ($plan?->show_contact_details ?? false); // Calculate years in business $establishedYear = $seller->created_at?->year ?? now()->year; $yearsInBusiness = now()->year - $establishedYear; if ($yearsInBusiness < 1) $yearsInBusiness = 1; // Get first image $galleryImages = $product->images_json; if (is_string($galleryImages)) { $decoded = json_decode($galleryImages, true); $galleryImages = (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) ? $decoded : [['original' => $galleryImages]]; } if (!is_array($galleryImages)) $galleryImages = []; $mainImage = !empty($galleryImages) ? asset('storage/' . ($galleryImages[0]['original'] ?? '')) : 'https://placehold.co/300x300?text=No+Image'; // Get specs from product $specs = []; if ($product->moq) $specs['MOQ'] = $product->moq . ' ' . ($product->unit->name ?? 'Pieces'); if ($product->specifications && is_array($product->specifications)) { foreach (array_slice($product->specifications, 0, 6) as $key => $value) { $specs[$key] = $value; } } @endphp
| {{ $label }} | {{ $value }} |