/**
  * Remove all items from the cart
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $post = $request->all();
     $errors = [];
     if ($request->method() == 'POST') {
         $validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required', 'street_name' => 'required', 'city' => 'required', 'country' => 'required', 'zipcode' => 'required']);
         // If everything is ok
         if (count($validator->errors()->all()) == 0) {
             Order::addOrder($post, Cart::total(), Cart::discount(), Cart::content());
             Cart::clearCoupons();
             Cart::destroy();
             return redirect()->route('checkout.order');
         }
         $errors = $validator->errors()->all();
     }
     return view('checkout.index', ['products' => Cart::content(), 'total' => Cart::total(), 'discount' => Cart::discount(), 'total_with_discount' => Cart::totalWithDiscount(), 'post' => $post, 'errors' => $errors]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return view('cart', ['products' => Cart::content(), 'discount' => Cart::discount(), 'coupons' => Cart::coupons()->toArray(), 'total' => Cart::total(), 'total_with_discount' => Cart::totalWithDiscount()]);
 }
 /**
  * Returns the biggest discount
  */
 public function testDiscount()
 {
     Cart::add(1, 'ITEM1', 1, '100');
     Cart::addCoupon('TEST20', 10);
     Cart::addCoupon('TEST10', 20);
     Cart::addCoupon('TEST50', 50);
     Cart::addCoupon('TEST40', 30);
     $this->assertEquals(50, Cart::discount());
 }