Current File : /home/tradevaly/www/resources/views/user/pages/product/checkOut.blade.php
@extends('frontend.layouts.app')
@push('title','Digital Advertising')

@section('content')
<form class="mt-4" action="{{route('user.check.store')}}" method="post">
  @csrf
    <div class="container">
        <div class="row">
        <div class="col-md-4 order-md-2 mb-4">
          <h4 class="d-flex justify-content-between align-items-center mb-3">
            <span class="text-muted">Your cart</span>
          </h4>
          <ul class="list-group mb-3">
              @php
              $total_price = 0;
              $discount_price= 0;
              @endphp
              @foreach($carts as $cart)
            <li class="list-group-item d-flex justify-content-between lh-condensed">
              <div>
                  
                <h6 class="my-0">{{substr(strtolower($cart->product->title), 0, 18)."..."}}</h6>
                <small class="text-muted">{{substr($cart->product->category->name, 0, 15)."..." }}</small>
              </div>
              <span class="text-muted">Qty: {{$cart->quantity}}</span>
              <span class="text-muted">{{$cart->product->price*$cart->quantity}}</span>
              @php 
              $total_price = $total_price + $cart->product->price*$cart->quantity;
              $discount_price = $discount_price+ (($cart->product->discount_price/100) * ($cart->product->price*$cart->quantity ));
              @endphp
            </li>
            @endforeach
            <!--<li class="list-group-item d-flex justify-content-between bg-light">-->
            <!--  <div class="text-success">-->
            <!--    <h6 class="my-0">Promo code</h6>-->
            <!--    <small>EXAMPLECODE</small>-->
            <!--  </div>-->
            <!--  <span class="text-success">-$5</span>-->
            <!--</li>-->
            
            <li class="list-group-item d-flex justify-content-between">
              <span>Sub Total (USD)</span>
              <strong>{{$total_price}}</strong>
            </li>
            <li class="list-group-item d-flex justify-content-between">
              <span>Discount (USD)</span>
              <strong>-{{$discount_price}}</strong>
            </li>
            <li class="list-group-item d-flex justify-content-between">
              <span>Tota; (USD)</span>
              <strong>{{$total_price - $discount_price}}</strong>
            </li>
          </ul>
          <div class="card p-2">
            <label for="firstName">name</label>
                <div class="form-check form-check-inline">
                  <input class="form-check-input" checked type="radio" name="payment_type" id="online" value="online">
                  <label class="form-check-label" for="online">Online Payment</label>
                </div>
                <div class="form-check form-check-inline">
                  <input class="form-check-input" type="radio" name="payment_type" id="offline" value="offline">
                  <label class="form-check-label" for="offline">Cash On Delevary</label>
                </div>
          </div>
          
          <div class="card p-2">
            <button class="btn btn-primary btn-lg btn-block" type="submit">Place Order</button>
          </div>
        </div>
        <div class="col-md-8 order-md-1">
          <h4 class="mb-3">Shiping address</h4>
            <div class="row">
              <div class="col-md-8 mb-3">
                <label for="firstName">name</label>
                <input type="text" name="name" class="form-control" id="firstName" placeholder="" value="{{$user->name}}" required>
                @error('name')
                    <span class="text-danger">{{ $message }} *</span>
                @enderror
              </div>
            </div>

            <div class="mb-3">
              <label for="email">Email <span class="text-muted">(Optional)</span></label>
              <input type="email" name="email" class="form-control" id="email" value="{{$user->email}}" placeholder="you@example.com">
                @error('email')
                    <span class="text-danger">{{ $message }} *</span>
                @enderror
            </div>

            <div class="mb-3">
              <label for="address">Address</label>
              <input type="text" name="address_1" class="form-control" value="{{$user->address}}" id="address" placeholder="1234 Main St" required>
              @error('address_1')
                    <span class="text-danger">{{ $message }} *</span>
                @enderror
            </div>

            <div class="mb-3">
              <label for="address2">Address 2 <span class="text-muted">(Optional)</span></label>
              <input type="text" name="address_2" class="form-control" id="address2" placeholder="Apartment or suite">
            </div>

            <div class="row">
              <div class="col-md-5 mb-3">
                <label for="country">Country</label>
                <select class="custom-select d-block w-100" name="country" id="country" required>
                  <option value="" disabled>Choose...</option>
                  @foreach($countries as $country)
                  <option value="{{$country->id}}" {{($user->country_id == $country->id)?'selected':''}}>{{$country->name}}</option>
                  @endforeach
                </select>
                @error('country')
                    <span class="text-danger">{{ $message }} *</span>
                @enderror
              </div>
              <div class="col-md-4 mb-3">
                <label for="state">City</label>
                <input type="text" class="form-control" name="city" id="zip" value="{{$user->city}}" placeholder="" required>
                @error('city')
                    <span class="text-danger">{{ $message }} *</span>
                @enderror
              </div>
              <div class="col-md-3 mb-3">
                <label for="number">Phone</label>
                <input type="text" name="phone" class="form-control" id="number" value="{{$user->phone}}" placeholder="Input Number" required/>
                @error('phone')
                    <span class="text-danger">{{ $message }} *</span>
                @enderror
              </div>
            </div>
        </div>
      </div>
    </div>
</form>
@endsection