@extends('layouts.frontend')

@section('content')
    <ol class="breadcrumb">
        <li><a href="{{ route('home') }}">Produits</a></li>
        <li><a href="{{ route('categories.show', $category->parent) }}">{{ $category->parent->name }}</a></li>
        <li class="active">{{ $category->name }}</li>
    </ol>
    {{-- <div class="row">
        <div class="col-md-12"  data-spy="affix" data-offset-top="100">
            <h1 class="page-header">
                {{ $category->name }}
                <small class="pull-right">{{ $category->brands()->count() }} marques | {{ $products->total() }} produits</small>
            </h1>
            @php
                $filterAttributes = $category->attributes->where('filtrable', 1);
            @endphp
            @if($filterAttributes->count() > 0)
            <div class="filter">
                <form class="form-inline" method="GET">
                    <div class="row">
                        <div class="col-md-10">
                            <div class="filter-inputs">
                                @foreach($filterAttributes as $itm)
                                    @include('shared.attributes.'. $itm->type .'.filter', ['attribute' => $itm])
                                @endforeach
                            </div>
                        </div>
                        <div class="filter-btn col-md-2">
                            @if(!empty($_GET))
                            <a href="{{ route('categories.produits', compact('category')) }}" class="btn btn-reset btn-default pull-right">
                                <i class="fa fa-times" aria-hidden="true"></i>
                            </a>
                            @endif
                            <button type="submit" class="btn btn-filter btn-default pull-right">
                                <i class="fa fa-filter" aria-hidden="true"></i> Filtrer
                            </button>
                        </div>
                    </div>
                </form>
            </div>
            @endif
        </div>
    </div> --}}
    
    <div class="row">
        <div class="col-md-2">
        {{-- <div class="col-md-2" data-spy="affix" data-offset-top="100"> --}}
            @include('frontend.products._filter')
        </div>
        <div class="col-md-10">
            <div class="row">
                @forelse($products as $product)
                    @include('frontend.products._product')
                @empty
                    <div class="col-md-4 col-md-offset-4 text-center">
                        <h3>Aucun produit trouvé</h3>
                    </div>
                @endforelse
            </div>
            <div class="row">
                <div class="col-md-12 text-center">
                    {{ $products->appends($_GET)->links() }}
                </div>
            </div>
        </div>
        
    </div>
@endsection