@extends('layouts.app') @push('styles') @endpush @section('content') @php $locale = current_locale(); $labels = match($locale) { 'en' => [ 'catalog' => 'Catalog', 'buy' => 'Add to cart', 'contact' => 'Contact us', 'details' => 'Product details', 'kit' => 'Included', 'warranty' => 'Warranty', 'shipping' => 'Delivery', 'related' => 'You may also like', 'features' => 'Advantages', ], 'ru' => [ 'catalog' => 'Каталог', 'buy' => 'В корзину', 'contact' => 'Связаться', 'details' => 'О товаре', 'kit' => 'Комплектация', 'warranty' => 'Гарантия', 'shipping' => 'Доставка', 'related' => 'Вам может понравиться', 'features' => 'Преимущества', ], default => [ 'catalog' => 'Kataloq', 'buy' => 'Səbətə əlavə et', 'contact' => 'Əlaqə saxla', 'details' => 'Məhsul haqqında', 'kit' => 'Dəstə daxildir', 'warranty' => 'Zəmanət', 'shipping' => 'Çatdırılma', 'related' => 'Bunlar da maraqlı ola bilər', 'features' => 'Xüsusiyyətlər', 'more' => 'Daha ətraflı', ], }; $gallery = collect([$product->main_image ?: $product->image]) ->merge($product->gallery_images ?? []) ->filter() ->unique() ->values(); $features = collect($product->feature_sections ?? [])->filter(fn ($item) => !empty($item['image']) || !empty($item['title']) || !empty($item['text'])); $colorVariants = collect($product->color_variants ?? []) ->filter(fn ($color) => !empty($color['name'])) ->values(); if ($features->isEmpty() && $product->description) { $features = collect([[ 'image' => $gallery->first(), 'title' => $product->short_description ?: $product->name, 'text' => $product->description, ]]); } $videoUrl = trim((string) $product->video); $videoEmbedUrl = null; $videoIsDirect = false; if ($videoUrl !== '') { $videoIsDirect = (bool) preg_match('/\.(mp4|webm|ogg)(\?.*)?$/i', $videoUrl); if (preg_match('/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([A-Za-z0-9_-]+)/i', $videoUrl, $matches)) { $videoEmbedUrl = 'https://www.youtube.com/embed/' . $matches[1]; } elseif (preg_match('/vimeo\.com\/(?:video\/)?(\d+)/i', $videoUrl, $matches)) { $videoEmbedUrl = 'https://player.vimeo.com/video/' . $matches[1]; } elseif (!$videoIsDirect) { $videoEmbedUrl = $videoUrl; } } @endphp
@if(image_has_webp($gallery->first())) @endif {{ $product->name }}
@if($gallery->count() > 1) @endif

{{ $product->name }}

@if($colorVariants->isNotEmpty())

Rəng

@foreach($colorVariants as $index => $color) @endforeach
@endif
{{ $product->formattedPrice() }} @if($product->old_price){{ $product->formattedOldPrice() }}@endif
@include('partials.product-purchase-button', ['product' => $product, 'label' => $labels['buy'], 'contactLabel' => $labels['contact']])
@if($features->isNotEmpty())
@foreach($features as $index => $feature)
@if(!empty($feature['image']))
@if(image_has_webp($feature['image'])) @endif {{ $feature['title'] ?? $product->name }}
@endif
@if(!empty($feature['title']))

{{ $feature['title'] }}

@endif @if(!empty($feature['text']))

{{ $feature['text'] }}

@endif
@endforeach
@endif @if($videoUrl)
Video

{{ $product->name }}

@if($videoIsDirect) @else @endif
@endif @if($product->description || $product->detailed_description || $product->kit_contents || $product->warranty_info || $product->shipping_info || $product->attributeValues->isNotEmpty())
@php($infoImage = $product->main_image ?: $product->image) @if(image_has_webp($infoImage)) @endif {{ $product->name }}

{{ $labels['features'] }}

@if($product->attributeValues->isNotEmpty()) @foreach($product->attributeValues->filter(fn($value) => $value->attribute?->show_on_product)->groupBy('attribute.name') as $attributeName => $values)
{{ $attributeName }}{{ $values->pluck('name')->implode(', ') }}
@endforeach @endif
{{ __('category') }}{{ $product->category->name }}
{{ __('status') }}{{ __('available') }}
@if($product->kit_contents)
{{ $labels['kit'] }}{{ $product->kit_contents }}
@endif @if($product->warranty_info)
{{ $labels['warranty'] }}{{ $product->warranty_info }}
@endif @if($product->shipping_info)
{{ $labels['shipping'] }}{{ $product->shipping_info }}
@endif
{{ $labels['more'] ?? 'More details' }}

{{ $product->detailed_description ?: $product->description }}

@endif @if($relatedProducts->count()) @endif
@endsection