@extends('layouts.frontend')

@section('title')
Products
@endsection
@section('content')
@php
    if($category){
        $cat_img = $category->image;
        $cat_banner_img = $category->banner_img;
        $title = $category->category_name;
        $description = $category->description;
    }
    
     if($subcategory){
        $cat_img = $subcategory->image;
        $cat_banner_img = $subcategory->banner_img;
        $title = $subcategory->title;
        $description = $subcategory->description;
    }
    
    if($childCategory){
        $cat_img = $childCategory->image;
        $cat_banner_img = $childCategory->banner_img;
        $title = $childCategory->title;
        $description = $childCategory->description;
    }
   
@endphp

<!--Category Logo Section Start-->
<section id="category-logo" class="py-5" style="background-image: url('{{asset('uploads/category_banner')}}/{{$cat_banner_img}}')">
    <div class="container">
        <div class="row">
            <div class="col-12">
                <div class="category-content">
                      <h3 class="text-white">{{$title}}</h3>
                    <!--<p class="cat-description text-white">{!!@$description!!}</p>-->
                </div>
            </div>
        </div>
    </div>
</section>
<!--Category Logo Section End-->

@if($description)
<!--Category about Section Start-->
<section class="py-5">
    <div class="container">
            <h4 class="text-center pb-5">About {{$title}}</h4>
        <div class="row">
            <div class="col-md-5">
               <img src="{{asset('uploads/category')}}/{{$cat_img}}" class="img-fluid" alt="">
            </div>
            <div class="col-md-7">
                <p class="text-justify">{!!@$description!!}</p>
            </div>
        </div>
    </div>
</section>
<!--Category about Section End-->
@endif


<section id="product-categories" class="pt-1 my-md-3 my-3">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <h3 style="color: {{$color->color_code}}">
                
                    All Products </h3>
                </div>
            </div>
            <div class="br"></div>
            <div class="row my-3">
                @forelse($products as $product)
                <div class="col-md-3 my-2">
                    <div class="card">
                        <div class="card-body pb-0">
                            <a href="{{url('product_details')}}/{{$product->id}}">
                            <div class="card-img">
                                <img src="{{asset('uploads/product')}}/{{$product->image}}" class="img-fluid" alt="">
                            </div>
                            </a>
                            <div class="card-title d-block">
                                <a href="{{url('product_details')}}/{{$product->id}}"><p class="text-center mt-3" style="color: {{$color->color_code}}">{{ Illuminate\Support\Str::limit($product->product_name, 15)}}</p></a>
                             {{--   <a href="{{url('product_details')}}/{{$product->id}}" class="btn btn-block">Show More</a> --}}
                            </div>
                        </div>
                    </div>
                </div>
                @empty
                <div class="col-lg-12 no_product">
	                	<h5>No Product Available</h5>
                </div>
                @endforelse
            </div>
        </div>
    </section>
@endsection