@extends('layouts.app') @section('title', 'Inventory Ledger') @section('page_title', 'Inventory Ledger') @section('content')

📥 Inventory

Live overview of product stock volumes and batch distributions.

@if(auth()->user()->isAdmin()) @endif
@if(session('success'))
🟢 {{ session('success') }}
@endif {{-- 🔍 SERVER-SIDE CONTROL UTILITIES --}}
@if(request('category')) @endif
@php $main = explode('-', request('category', ''))[0]; @endphp @if($main == 'barista' || $main == 'kitchen')
@php $subs = ($main == 'barista') ? ['packaging' => 'Packaging', 'syrups' => 'Syrups & Purees', 'coffee' => 'Coffee, Tea & Powders', 'dairy' => 'Dairy & Drinks', 'snacks' => 'Snacks & Add-ons'] : ['dry' => 'Dry Ingredients & Seasonings', 'sauces' => 'Sauces & Condiments', 'carbs' => 'Carbs & Staples', 'protein' => 'Frozen Protein & Processed', 'fresh' => 'Fresh Produce', 'packaging' => 'Kitchen Packaging']; @endphp @foreach($subs as $slug => $label) {{ $label }} @endforeach
@endif
{{-- 📊 Main Ledger Table --}}
@if(auth()->user()->isAdmin()) @endif @forelse($products as $product) {{-- UPDATED SYSTEM STATUS COLUMN --}} @if(auth()->user()->isAdmin()) @endif @empty @endforelse
Product Name Category Current Stock Min Stock Alert Earliest Batch Expiry System StatusActions
{{ $product->name }} {{ explode('-', $product->category)[0] }} {{ ucwords(str_replace('-', ' ', $product->category)) }} {{ $product->stock }} {{ $product->unit }} {{ $product->min_stock }} {{ $product->unit }} @php $nearest = $product->batches() ->where('remaining_quantity', '>', 0) ->orderByRaw('expiry_date IS NULL ASC') ->orderBy('expiry_date', 'asc') ->first(); @endphp @if($nearest && $nearest->expiry_date) 📅 {{ \Carbon\Carbon::parse($nearest->expiry_date)->format('d M Y') }} @elseif($nearest) No expiry @else No batches active @endif @php $isExpired = $nearest && $nearest->expiry_date && \Carbon\Carbon::parse($nearest->expiry_date)->isPast(); $isLowStock = $product->stock <= $product->min_stock && $product->stock > 0; $isOutOfStock = $product->stock <= 0; @endphp {{ $isExpired ? 'Expired' : ($isOutOfStock ? 'Out of Stock' : ($isLowStock ? 'Low Stock' : 'Stable')) }}
Edit
@csrf @method('DELETE')
No products found.
{{ $products->links() }}
@endsection