@extends('Kitchen.layout') @section('content') {{-- Page Header --}}
Back
{{ $category->category }} Products
Products available under {{ $category->category }}
Total Products: {{ $products->count() }}
{{-- Category Details --}}
@php $categoryImage = null; if (!empty($category->image)) { if ( str_starts_with($category->image, 'http://') || str_starts_with($category->image, 'https://') ) { $categoryImage = $category->image; } else { $categoryImage = asset( 'storage/' . $category->image ); } } @endphp @if($categoryImage) {{ $category->category }} @else
@endif
{{ $category->category }}
Category ID: {{ $category->id }}
{{-- Product Table --}}
@forelse($products as $product) @php $productImage = null; $images = $product->images; /* |-------------------------------------------------------------------------- | Handle cast array, JSON and normal string |-------------------------------------------------------------------------- */ if (is_array($images) && !empty($images)) { $productImage = $images[0] ?? null; } elseif (is_string($images)) { $decodedImages = json_decode( $images, true ); if ( json_last_error() === JSON_ERROR_NONE && is_array($decodedImages) ) { $productImage = $decodedImages[0] ?? null; } elseif (!empty($images)) { $productImage = $images; } } /* |-------------------------------------------------------------------------- | Build complete image URL |-------------------------------------------------------------------------- */ if (!empty($productImage)) { if ( !str_starts_with($productImage, 'http://') && !str_starts_with($productImage, 'https://') ) { $productImage = asset( 'storage/' . ltrim( $productImage, '/' ) ); } } @endphp @empty @endforelse
S.No Image Product ID Product Name Weight Machine ID Unit MRP Price Stock Status
{{ $loop->iteration }} @if($productImage) {{ $product->product_name }} @else No Image @endif {{ $product->product_id ?? $product->id }} {{ $product->product_name }} {{ $product->weight_machine_id ?? '-' }} @if(!empty($product->unit_value)) {{ $product->unit_value }} @endif {{ $product->unit ?? '-' }} ₹{{ number_format( (float) ($product->mrp ?? 0), 2 ) }} ₹{{ number_format( (float) ($product->price ?? 0), 2 ) }} @if((float) $product->stock <= 0) {{ $product->stock ?? 0 }} @elseif((float) $product->stock <= 5) {{ $product->stock }} @else {{ $product->stock }} @endif @if((bool) $product->is_active) Active @else Inactive @endif
No products found under this category.
@endsection