@extends('layouts.app') @section('title', $category->name . ' - LaravelStore') @section('content')

{{ $category->name }}

{{ $category->description }}

@forelse($products as $product) @php $hasActiveDiscount = $product->hasDiscount(); $hasScheduledDiscount = $product->hasScheduledDiscount(); $hasCoupon = $activeCoupons->first(fn($c) => $c->appliesToProduct($product->id)); @endphp
@php $imgSource = $product->featured_image ?: $product->image; $imgSrc = null; if ($imgSource) { if (str_starts_with($imgSource, 'data:') || str_starts_with($imgSource, 'http')) { $imgSrc = $imgSource; } elseif (str_starts_with($imgSource, '/storage/')) { $imgSrc = asset(substr($imgSource, 1)); } else { $imgSrc = asset('storage/' . $imgSource); } } @endphp @if($imgSrc) {{ $product->name }} @else
@endif
{{ $product->is_digital ? 'Digital' : 'Físico' }} @if($hasCoupon) Cupão @endif @if($hasActiveDiscount) -{{ $product->getDiscountPercent() }}% @elseif($hasScheduledDiscount) Breve @endif
{{ $product->name }}

{{ Str::limit($product->description, 50) }}

@if($hasActiveDiscount)
{{ number_format($product->price, 2) }}€

{{ number_format($product->discount_price, 2) }}€

@else

{{ number_format($product->price, 2) }}€

@endif @if(!$product->is_digital && $product->stock > 0) {{ $product->stock }} em stock @elseif(!$product->is_digital) Esgotado @endif
@if($hasActiveDiscount && $product->getDiscountEndFormatted()) Termina {{ $product->getDiscountEndFormatted() }} @elseif($hasScheduledDiscount) Inicia {{ $product->getDiscountStartFormatted() }} @endif Ver Detalhes
@empty
Nenhum produto encontrado nesta categoria.
@endforelse
{{ $products->links() }}
@endsection