@extends('user.app')

@section('main-content')

<div class="banner-part">

     <img src="{{ asset('user/images/inner-ban1.jpg') }}" alt="">    

    <div class="inner-ban-tx">

        <h2>cart</h2>

    </div>

</div>

<section class="cart-area ptb-100">

            <div class="container">

             

                    <div class="row">
                            @php 
                                $totalprice = 0;
                            @endphp
                       
                            @if(isset($carts))
                             <div class="col-lg-12 col-md-12">
                                <div class="cart-table table-responsive">
                                    @include('user/layouts/messages');
                                    <table class="table table-bordered">

                                        <thead>

                                            <tr>

                                                <th scope="col">Product</th>

                                                <th scope="col">Product Name</th>

                                                <th scope="col">Price</th>

                                                <th scope="col">Quantity</th>

                                                <th scope="col">Total</th>

                                                <th scope="col">Action</th>

                                            </tr>

                                        </thead>

                                        <tbody>
                                            {{-- {{  $i = 1; }} --}}
                                           
                                            @foreach($carts as $cart)
                                             @php
                                             $totalprice =  $totalprice + $cart->price;
                                             $coursesimage = coursesimage($cart->product_id);
                                             @endphp
                                                <tr>

                                                <td class="product-thumbnail">          
                                                    <a href="{{url('/')}}/enrol/{{ $cart->slug }}"><img src="{{ $coursesimage }}" alt="shop"></a>
                                                </td>
                                                <td> {{$cart->name}}</td>
                                                <td>{{$cart->price}}</td>
                                                <td class="quantity">
                                                    <input type="number" name="quantity" class="form-control" value="{{$cart->quantity}}" disabled="disabled">
                                                </td>
                                                <td>{{$cart->price}}</td>

                                                <td>
                                                      <form action="{{ route('cart.destroy', $cart->id ) }}" method="POST">
                                                          {{ method_field('DELETE') }}
                                                          {{ csrf_field() }}
                                                          <button><i class="fa fa-trash"></i> </button>
                                                      </form>  
                                                </td>


                                            </tr>
                                         
                                            @endforeach
                                            
                                        </tbody>

                                    </table>

                                </div>
                            </div>
                            <div class="col-lg-8 col-md-12">

                                <div class="cart-buttons">

                                    {{-- <button type="submit" class="btn btn-primary">Update Cart</button> --}}

                                    <a href="{{ url('/') }}" class="btn btn-primary">Continue Shopping</a>

                                </div>

                            </div>

                            <div class="col-lg-4 col-md-12">

                                <div class="cart-total">

                                    <h3>Cart Totals</h3>

                                    

                                    <div class="cart-total-table table-responsive">

                                        <table class="table">

                                            <tbody>

                                                <tr>

                                                    <td>Subtotal</td>

                                                    <td class="amount">{{ $totalprice }}</td>

                                                </tr>

                                              {{--   <tr>

                                                    <td>Shipping</td>

                                                    <td>$10.00</td>

                                                </tr> --}}

                                                <tr>

                                                    <td>Total</td>

                                                    <td>{{ $totalprice }}</td>

                                                </tr>

                                            </tbody>

                                        </table>

                                    </div>

                                    <div class="proceed-to-checkout">
                                         <a href="{{ url('/checkout') }}" class="btn btn-primary">Proceed To Checkout</a>
                                    </div>

                                </div>

                            </div>
                            @else
                            <div class="col-lg-12 col-md-12">
                                No Products Found
                            </div>
                            @endif

                        

                      

                    </div>

            </div>

        </section>



<div class="clearfix"></div>



@endsection