@foreach($cartinfo as $key=>$value)
{{$value->name}}
@php $product = \App\Models\Product::find($value->id); $sizesList = collect(); $colorsList = collect(); if ($product) { $sizeIds = \App\Models\ProductVariantPrice::where('product_id', $product->id)->whereNotNull('size_id')->pluck('size_id')->unique()->filter(); $colorIds = \App\Models\ProductVariantPrice::where('product_id', $product->id)->whereNotNull('color_id')->pluck('color_id')->unique()->filter(); if ($sizeIds->isNotEmpty()) { $sizesList = \App\Models\Size::whereIn('id', $sizeIds)->get(); } if ($colorIds->isNotEmpty()) { $colorsList = \App\Models\Color::whereIn('id', $colorIds)->get(); } if ($sizesList->isEmpty() && $colorsList->isEmpty()) { $sizesList = $product->sizes ?? collect(); $colorsList = $product->colors ?? collect(); } } $hasSizes = $sizesList->isNotEmpty(); $hasColors = $colorsList->isNotEmpty(); $currentSizeId = $value->options->size_id ?? ''; $currentColorId = $value->options->color_id ?? ''; @endphp @if($hasSizes || $hasColors)
@if($hasSizes)
@endif @if($hasColors)
@endif
@endif
{{$value->price}} {{$value->price * $value->qty}} @endforeach