@php use Illuminate\Support\Facades\Storage; $img = $p->mainImage ?? null; $disk = $img->disk ?? 'public'; $thumb = $img ? data_get($img->meta, 'thumb_312x340') : null; $src = $img ? Storage::disk($disk)->url($thumb ?: $img->path) : asset('assets/img/product/placeholder.jpg'); $price = (float) ($p->price ?? 0); $oldPrice = data_get($p, 'old_price'); // dacă ai câmpul $hasDiscount = is_numeric($oldPrice) && $oldPrice > $price; $isOnSale = ($showSale ?? false) || $hasDiscount || ($p->relationLoaded('categories') && optional($p->categories)->contains(fn($c) => $c->slug === 'on-sale')); @endphp @push('styles') @endpush
{{ $p->name }} @if($isOnSale)
{{ $hasDiscount ? (round(100 - ($price / $oldPrice * 100)).'% off') : 'Sale' }}
@endif
{{ $p->brand->name ?? '—' }}
{{ $p->name }}
@push('styles') @endpush @push('scripts') @endpush