{{--
--}}
@foreach ($categoryProducts as $product)
{{-- Call the static getDiscountPrice() method in the Product.php Model to determine the final price of a product because a product can have a discount from TWO things: either a `CATEGORY` discount or `PRODUCT` discout --}} @php $getDiscountPrice = \App\Models\Product::getDiscountPrice($product['id']); @endphp @if ($getDiscountPrice > 0) {{-- If there's a discount on the price, show the price before (the original price) and after (the new price) the discount --}}
EGP{{ $getDiscountPrice }}
EGP{{ $product['product_price'] }}
@else {{-- if there's no discount on the price, show the original price --}}
EGP{{ $product['product_price'] }}
@endif
@php $isProductNew = \App\Models\Product::isProductNew($product['id']) @endphp @if ($isProductNew == 'Yes')
NEW
@endif
@endforeach