@extends('layouts.customer') @section('title') Click & Get - Online Shop @endsection @if (!auth()->check()) @include('layouts.inc.IntroVideo') @endif @section('content')

Welcome to Click & Get

Your One-Stop Online Shop for Quality Products

Explore New Arrivals
@if(session('status')) @endif

Delicacies

@foreach ($product as $item)
Product Image
{{ Str::limit($item->name, 15) }}
{{ $item->user->shop_name }}

{{ Str::limit($item->description, 20) }}

{{ $item->user->shop_name }} @if ($item->qty <= 10) {{ $item->qty }} left in stock! @elseif ($item->qty > 10)   @endif

@if($item->productPrices->isNotEmpty()) @php // Fetch the latest active price $latestActivePrice = $item->productPrices() ->where('is_active', 1) ->latest('created_at') ->first(); // Fetch the previous active price $previousActivePrice = null; if ($latestActivePrice) { $previousActivePrice = $item->productPrices() ->where('is_active', 1) ->where('created_at', '<', $latestActivePrice->created_at) ->latest('created_at') ->first(); } // Calculate the discount $discountedPrice = $latestActivePrice ? $latestActivePrice->price : null; $originalPrice = $previousActivePrice ? $previousActivePrice->price : null; $discountPercent = $originalPrice && $discountedPrice ? (($originalPrice - $discountedPrice) / $originalPrice) * 100 : null; @endphp @if($discountedPrice && $discountPercent > 0) ₱ {{ number_format($discountedPrice, 2, '.', ',') }} @if($originalPrice) ₱ {{ number_format($originalPrice, 2, '.', ',') }} @endif ({{ number_format($discountPercent, 2) }}% off) @else ₱ {{ number_format($discountedPrice, 2, '.', ',') }} @endif @endif

@csrf
@if($item->qty > 0)
@endif
@endforeach
@endsection @section('scripts') @section('css')