@props([ 'product', 'showCountdown' => false, ]) @php $countdownEndIso = null; if ($showCountdown && isset($product)) { $discountModel = null; if ($product->relationLoaded('discount')) { $loadedDiscount = $product->getRelation('discount'); if ($loadedDiscount && $loadedDiscount->type === 'amazing' && \Illuminate\Support\Carbon::parse($loadedDiscount->end_time)->greaterThan(now())) { $discountModel = $loadedDiscount; } } if (!$discountModel) { $discountModel = $product->discount() ->where('type', 'amazing') ->where('start_time', '<=', now()) ->where('end_time', '>', now()) ->latest('end_time') ->first(); } if (!$discountModel) { $items = $product->relationLoaded('productItem') ? $product->getRelation('productItem') : $product->productItem() ->whereHas('discount', function ($query) { $query->where('type', 'amazing') ->where('start_time', '<=', now()) ->where('end_time', '>', now()); }) ->with(['discount' => function ($query) { $query->where('type', 'amazing') ->where('start_time', '<=', now()) ->where('end_time', '>', now()); }]) ->get(); foreach ($items as $item) { $itemDiscount = null; if ($item->relationLoaded('discount')) { $loadedItemDiscount = $item->getRelation('discount'); if ($loadedItemDiscount && $loadedItemDiscount->type === 'amazing' && \Illuminate\Support\Carbon::parse($loadedItemDiscount->end_time)->greaterThan(now())) { $itemDiscount = $loadedItemDiscount; } } else { $itemDiscount = $item->discount() ->where('type', 'amazing') ->where('start_time', '<=', now()) ->where('end_time', '>', now()) ->latest('end_time') ->first(); } if ($itemDiscount) { $discountModel = $itemDiscount; break; } } } if ($discountModel) { $discountEnd = \Illuminate\Support\Carbon::parse($discountModel->end_time); if ($discountEnd->greaterThan(now())) { $countdownEndIso = $discountEnd->toIso8601String(); } } } @endphp @include('components.front.countdown.assets')
مدل : {{isset($product) ? $product->model : ""}}
--}}کد : {{isset($product) ? $product->vendor_code : ""}}
{{ number_format($displayPrice) }} ریال
عیار : {{isset($product) && $product->karat? $product->karat->title : "" }}
@php $productItems = $product->productItem ?? collect(); // جلوگیری از null // فقط آیتمهایی که is_sold == 0 هستند $productItems = $productItems->where('is_sold', 0); // مرتبسازی بر اساس وزن $productItems = $productItems->sortBy('weight')->values(); $itemCount = $productItems->count(); @endphp @if($itemCount > 1) @php $firstWeight = (float) $productItems->first()->weight; $lastWeight = (float) $productItems->last()->weight; @endphp @if($firstWeight === $lastWeight)وزن {{ $firstWeight }}
@elseاز وزن {{ $firstWeight }} تا {{ $lastWeight }}
@endif @elseif($itemCount === 1)وزن {{ (float) $productItems->first()->weight }}
@elseوزن {{ (float) $product->default_weight }}
@endifمناسب : @if(isset($product)) @foreach($product->productUsage as $key => $proUsage) {{$proUsage->title}} {{$key !== count($product->productUsage) -1 ? ',' : ''}} @endforeach @endif
@endif