@php $critical = $lots->filter(fn($l) => $l->expiry_date && now()->diffInDays($l->expiry_date, false) <= 7)->count(); $warning = $lots->filter(fn($l) => $l->expiry_date && now()->diffInDays($l->expiry_date, false) > 7 && now()->diffInDays($l->expiry_date, false) <= 14)->count(); $upcoming = $lots->count() - $critical - $warning; @endphp
{{ $critical }}
Critical (≤7 days)
{{ $warning }}
Warning (8-14 days)
{{ $upcoming }}
Upcoming (>14 days)
{{ $lots->count() }}
Total Lots
@if($lots->count() > 0) @foreach($lots as $lot) @php $daysLeft = now()->diffInDays($lot->expiry_date, false); $stock = $lot->stockLevels->sum('qty'); @endphp @endforeach
Lot # Batch # Product Expiry Date Days Left Stock Action
{{ $lot->lot_no }} {{ $lot->batch_no ?? '-' }} {{ $lot->product->name ?? 'Unknown' }}
{{ $lot->product->sku ?? '' }}
{{ $lot->expiry_date->format('d M Y') }} @if($daysLeft <= 7) {{ $daysLeft }} days @elseif($daysLeft <= 14) {{ $daysLeft }} days @else {{ $daysLeft }} days @endif {{ number_format($stock, 2) }} {{ $lot->product->unit->short_name ?? 'PCS' }} View
@else

No Expiring Lots

No lots are expiring within the next {{ $days }} days.

@endif