@extends('user.app')

@section('main-content')

<div class="banner-part">

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

    <div class="inner-ban-tx">
        <div class="container">
            <div class="row">
                <h2>cart</h2>
                <ul class="breadcrumbs">
                    @php
                        echo '<li><a href="'.url('/').'">Home</a></li>';
                        echo '<li class="selected">Cart</li>';
                    @endphp
                </ul>
            </div>
        </div>
    </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;
                                             @endphp
                                                <tr>
{{-- 
                                                <td class="product-thumbnail">
                                                    {{$cart->product_id}}

                                                    <a href="#"><img src="images/3.jpg" 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 class="cart-coupon">

                                    <h4>Coupon</h4>

                                    <p>Enter your coupon code if you have one.</p>

                                    <div class="cuppon-form">

                                        <input type="text" class="form-control" placeholder="Coupon Code">

                                        <button type="submit" class="btn btn-primary">Apply Coupon</button>

                                    </div>

                                </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