@if (setting('MEGA_CAT_PRODUCT_STATUS') != 0 || setting('MEGA_CAT_PRODUCT_STATUS') == '')
@if (!empty(setting('mega_cat')))
    @foreach (json_decode(setting('mega_cat')) as $c)
        @php
            $cat = DB::table('categories')->where('id', $c)->first();
            $productIds = DB::table('category_product')->where('category_id', $c)->get()->pluck('product_id');
            $products = \App\Models\Product::whereIn('id', $productIds)->take(6)->where('status', 1)->get();
        @endphp
        @if ($cat)
            @if ($products->count() > 0)
                <div class="products">
                    <div class="container">
                        <h3 class="title"><span>{{ $cat->name }} </span><a
                                href="{{ route('category.product', $cat->slug) }}">View All</a>
                        </h3>
                        <div class="row autoplay slick-slides">
                            @forelse ($products as $product)
                                <x-product-grid-view :product="$product" classes="" />
                            @empty
                                <x-product-empty-component />
                            @endforelse

                        </div>
                    </div>
                </div>
            @endif
        @endif
    @endforeach
@endif
@endif