@extends('User.layouts.master')
@section('body')


@php

$activeslider = DB::table('sliders')->orderBy('id','DESC')->first();
$slidermore = DB::table('sliders')->orderBy('id','DESC')->skip(1)->limit(2)->get();
$setting = DB::table('settings')->first();

@endphp

<main>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-12">
                <div class="main-marquee">
                    <marquee>{{$setting->marque}}</marquee>
                </div>
                <div id="carouselExampleFade" class="carousel slide carousel-fade pt-2" data-bs-ride="carousel">
                    <div class="carousel-inner">
                        <div class="carousel-item active">
                            <a href="{{ $activeslider->url }}"><img class="d-block w-100 rounded" src="{{ asset('public/sliderImage') }}/{{ $activeslider->image }}" id="sliderimage"></a>
                        </div>
                        @if (isset($slidermore))
                        @foreach ($slidermore as $slidermoredata)
                        <div class="carousel-item">
                            <a href="{{ $slidermoredata->url }}">
                                <img src="{{ asset('public/sliderImage') }}/{{ $slidermoredata->image }}" class="d-block w-100 rounded banner-image">
                            </a>
                        </div>
                        @endforeach
                        @endif

                    </div>
                    <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleFade" data-bs-slide="prev">
                        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                        <span class="visually-hidden">Previous</span>
                    </button>
                    <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleFade" data-bs-slide="next">
                        <span class="carousel-control-next-icon" aria-hidden="true"></span>
                        <span class="visually-hidden">Next</span>
                    </button>
                </div>
            </div>
        </div>
    </div>

    <section>
        <div class="container">

            <div class="head mb-4 mt-5"></div>

            <div class="row g-3">
                @php

                $category=DB::table('product_category')
                ->join('product_item', 'product_category.item_id', 'product_item.id')
                ->select('product_category.*','product_item.item_name')->get();
                @endphp

                @if(isset($category))
                @foreach($category as $i)
                @php
                $category_name=str_replace(" ","-",$i->category_name)
                @endphp
                <div class="col-6 col-lg-2">
                    <div class="category h-100">
                        <a href="{{url('category')}}/{{$category_name}}/{{$i->id}}" class="category__link">
                            @if($i->image == NULL)
                            <!-- {{ asset('public/itemImage') }}/{{ $i->image }} -->
                            <img src="{{ asset('public/fontdev/') }}/img/demo.jpg" class="category__img">
                            @else
                            <img src="{{ asset('public/categoryImage/') }}/{{ $i->image }}" class="category__img">
                            @endif

                            <h5 class="category__title" style="font-size: 14px;">{{ $i->category_name}}</h5>
                        </a>
                    </div>
                </div>

                @endforeach
                @endif
            </div>

            @php
            $offerbanner = DB::table('explore_banners')->limit(4)->get();
            @endphp

            @php
            $itemcat = DB::table('product_item')->orderBy('sl','ASC')->limit(5)->get();
            @endphp

            @if(isset($itemcat))
            @foreach($itemcat as $itemcats)
            @php
            $item_name=str_replace(" ","-",$itemcats->item_name);
            $product = DB::table('product_productinfo')->where('item_id',$itemcats->id)->where('status',1)->orderBy('id','DESC')->limit(12)->get();
            @endphp



            @endforeach
            @endif
        </div>
    </section>
</main>




@endsection