@extends('layouts.backend') 
@section('content-header')
<h1>
    Produits
    <small>{{ $products->total() }} produits</small>
</h1>
@endsection
 
@section('content')
<div class="row">
    <div class="col-md-9">
        <div class="box box-solid" style="min-height: 90px;">
            <div class="box-body">

                <h3><a href="{{ route('backend.companies.show', $company->id) }}" class="btn btn-success"><i class="fa fa-chevron-left" aria-hidden="true"></i>
 Retour</a> {{ $company->name }}</h3>
            </div>
        </div>
    </div>
    <div class="col-md-3">
        <div class="info-box">
            <span class="info-box-icon bg-green"><i class="fa fa-cubes"></i></span>

            <div class="info-box-content">
                <span class="info-box-text">Produits</span>
                <span class="info-box-number">{{ $company->products()->count() }}</span>
            </div>
        </div>
    </div>
    <div class="clearfix"></div>
    <div class="col-md-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">

                </h3>

                <div class="box-tools">
                    {!! Form::open(['route' => ['backend.companies.products.index', $company->id], 'class' => 'form-inline', 'method' => 'GET'])
                    !!}
                    <div class="input-group">

                        <input type="text" name="q" class="form-control pull-right" placeholder="Recherche..." value="{{ request('q') }}" style="width: 300px;">

                        <div class="input-group-btn">
                            @if(request('q') || request('company'))
                            <a href="{{ route('backend.companies.products.index', $company->id) }}" class="btn btn-danger"><i class="fa fa-times" aria-hidden="true"></i></a>                            @endif
                            <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
                            <a href="{{ route('backend.companies.products.select', $company->id) }}" data-toggle="modal" data-target="#modal-xlg" class="btn btn-success">
                                <i class="fa fa-plus" aria-hidden="true"></i> Ajouter un produit
                            </a>
                        </div>
                    </div>
                    {!! Form::close() !!}

                </div>
            </div>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
                <table class="table table-hover">
                    <tbody>
                        <tr>
                            <th>ID</th>
                            <th>Ref</th>
                            <th>Nom du produit</th>
                            <th>Categorie</th>
                            <th>Marque</th>
                            <th>Actif</th>
                            <th style="width: 150px;" class="text-right">Action</th>
                        </tr>
                        @foreach($products as $product)
                        <tr>
                            <td>{{ $product->id }}</td>
                            <td>{{ $product->ref }}</td>
                            <td>{{ $product->name }}</td>
                            <td>{{ isset($product->category)?$product->category->name:null }}</td>
                            <td>{{ isset($product->brand)?$product->brand->name:null }}</td>
                            <td>
                                @if($product->published)
                                <i class="fa fa-check-square-o fa-lg" style="color:green" aria-hidden="true"></i> @else
                                <i class="fa fa-ban fa-lg danger" style="color:red" aria-hidden="true"></i> @endif
                            </td>
                            <td class="text-right">
                                <a href="{{ route('backend.products.show', $product->id) }}" class="btn btn-sm btn-success" target="_blank"><i class="fa fa-eye" aria-hidden="true"></i></a>
                                <a href="{{ route('backend.companies.products.delete', [$company->id, $product->id]) }}" class="btn btn-sm btn-danger" data-confirm="delete"><i class="fa fa-trash" aria-hidden="true"></i></a>
                            </td>
                        </tr>
                        @endforeach

                    </tbody>
                </table>
            </div>
            <!-- /.box-body -->
            <div class="box-footer clearfix">
                {{ $products->appends(['q' => request('q'), 'company' => request('company')])->links() }}
            </div>
        </div>
        <!-- /.box -->
    </div>
</div>
@endsection