@extends ('includes.main-layout')

@section('styles')

@endsection

@section('header')
    @include('includes.header')
@endsection

@section('content')
    <div class="row mt-4">
        <div class="col-md-12">
        @include('includes.errors')
            <div class="card">
                <div class="card-body">
                    <h3 class="card-title">Produits en panier : <span class="badge bg-dark text-white p-2">{{Cart::content()->count()}}</span></h3>
                    <table class="table table-dark mx-auto">
                        <thead class="thead-default">
                            <tr>
                            <th></th>
                                <th>Libellé</th>
                                <th>Prix</th>
                                <th>Qté</th>
                                <th>Total</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach(Cart::content() as $product)
                            <tr>
                                <td><img src="{{URL::to('images/'.$product->model->file)}}" height="50" width="50" alt=""></td>
                                <td scope="row">{{$product->name}}</td>
                                <td>{{$product->price}} dh</td>
                                <td>
                                    <a href="{{route('cart.decrease',['id'=>$product->rowId,'qte'=>$product->qty])}}" class="btn bg-light" id="moins">-</a>
                                    <input type="text" style="width:8%;text-align:center;padding:5px;" class="qte" id="qte" name="qte" value="{{$product->qty}}">
                                    <a href="{{route('cart.increase',['id'=>$product->rowId,'qte'=>$product->qty])}}" class="btn bg-light" id="plus">+</a>
                                </td>
                                <td>{{$product->total}} dh</td>
                                <td><a href="{{route('cart.delete',['id'=>$product->rowId])}}" class="btn btn-danger btn-xs"><i class="fa fa-trash"></i></a></td>
                            </tr> 
                            @endforeach
                        </tbody>
                    </table>
                    <p class="lead">Total: <span class="badge bg-success text-white">{{Cart::total()}} dh</span></p>
                    <a href="{{route('cart.checkout')}}" class="btn btn-success">Valider</a>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('footer')

@endsection

@section('scripts')

@endsection
