/** * @Authorized('/login') * @param CheckOutBindingModel $input * @param Cart $cart */ public function doCheckout(CheckOutBindingModel $input, Cart $cart) { $this->validation->validate($input, ['names' => 'required|min:5', 'email' => 'required|min:5|email', 'mobile' => 'required', 'address' => 'required']); if ($this->validation->getErrors() == false) { $cart->checkout($input->names, $input->email, $input->mobile, $input->address); $this->emptyCart(); return $this->redirect->to('/products')->withSuccess("You have sent your order successfully.")->go(); } $this->redirect->to('/cart/checkout')->withErrors($this->validation->getErrors())->withInput($input)->go(); }