public function useCode(Request $request) { if ($request->ajax()) { $code = $request->get("code"); $percent = DiscountCode::changeCodeToPercent($code); $cart = new CartController(); $products = $cart->getProduct(); $total = $cart->subTotalPrice($products); $total = $total * ($percent / 100); $total = number_format($total); Session::put("codeDiscount", $code); return $total; } else { return redirect()->route("home"); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $input = Request()->all(); extract($input); $data['order_id'] = "MAH-PUN-REG-" . rand(1000, 9999); foreach ($ids as $product_id) { $data['product_id'] = $product_id; CartController::forget($product_id); Orders::create($data); } $cust_id = \Auth::user()->id; return redirect('pages/order/' . $data['order_id']); }
/** * Show the application dashboard to the user. * * @return Response */ public function handle() { $cartSummary = CartController::getCartSummaryStaticHTML(); $breadcrumbParam = null; $trainNum = Input::get("train_num"); $trainName = Input::get("train_name"); $srcStation = Input::get("source_station"); $destStation = Input::get("destination_station"); $journeyDate = Input::get("journey_date"); $stationCode = Input::get("station_code"); $searchType = Input::get("search_type"); $restaurantId = Input::get("restaurant_id"); if (!empty($trainNum) && !empty($trainName) && !empty($journeyDate) && !empty($stationCode)) { $breadcrumbParam = Input::except("login", "_token", 'checkout', 'completeDetails'); $bookingDetailHeader = array("DATE" => date('D , d M Y', strtotime($journeyDate)), "TRAIN_NUM" => $trainNum, "TRAIN_NAME" => "<i class='fa fa-train pr10'></i>" . strtoupper($trainName), "STATION_SELECTED" => "<i class='fa fa-map-marker pr10'></i>" . $stationCode); return view('cart-checkout')->with('cartSummary', $cartSummary)->with('breadcrumbParam', $breadcrumbParam)->with("parameters", Session::get("checkoutFormParamters"))->with('bookingDetailHeader', $bookingDetailHeader); } else { App::abort(400); } }
public function getDetail($restaurantId) { if (!empty($restaurantId)) { $restView = null; $url = API_HOST . RESTAURANT; $this->curl->setOption(CURLOPT_HEADER, true); $this->curl->setOption(CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $response = $this->curl->get($url, array("url" => $restaurantId)); $response = json_decode($response, true); if (isset($response) && isset($response['responseStatus']) && $response['responseStatus'] === true) { $restaurantMenu = $this->getRestaurantMenu($response['id']); $restView = view("restaurant-page")->with("showDetail", true)->with("name", $response['name'])->with("resInternalId", $response['id'])->with("stationName", Input::get("station_name"))->with("minimumOrder", $response['minOrderValue'])->with("openTime", $response['openTime'])->with("closeTime", $response['closeTime'])->with("contactNo", $response['contactNumber'])->with("deliveryCharges", $response['deliveryCharges'])->with("restaurantMenu", $restaurantMenu); } else { return view("restaurant-page")->with("noRestFound", true); } } else { \App::abort(404); } $this->cleanUpCartIfNeeded($restaurantId); $cartController = new CartController(); $cartContent = $cartController->getCartContent(); $breadcrumbParam = null; $trainNum = Input::get("train_num"); $trainName = Input::get("train_name"); $srcStation = Input::get("source_station"); $destStation = Input::get("destination_station"); $journeyDate = Input::get("journey_date"); $stationCode = Input::get("station_code"); $searchType = Input::get("search_type"); $stationName = Input::get("station_name"); $deliveryTime = Input::get("delivery_time"); $restaurantHeader = null; $checkoutFormParamters = array("train_num" => $trainNum, "train_name" => $trainName, "source_station" => $srcStation, "destination_station" => $destStation, "journey_date" => $journeyDate, "station_code" => $stationCode, "search_type" => $searchType, "restaurant_id" => $response['id'], "restaurant_name" => $response['name'], "delivery_charges" => $response['deliveryCharges'], "station_name" => $stationName, "delivery_time" => $deliveryTime); Session::put('checkoutFormParamters', $checkoutFormParamters); if (!empty($journeyDate) && !empty($trainNum) && !empty($trainName) && !empty($srcStation) && !empty($destStation) && !empty($stationCode) && !empty($journeyDate) && !empty($searchType)) { $restaurantHeader = array("DATE" => $journeyDate, "ROUTE" => "<i class='fa fa-map-marker pr10'></i>" . $srcStation . " TO " . $destStation, "TRAIN_NUM" => "<i class='fa fa-train pr10'></i> [ " . $trainNum . " ] " . $trainName, "STATION_SELECTED" => "<i class='fa fa-map-marker pr10'></i>" . $stationCode); $breadcrumbParam = Input::except("login", "_token", 'checkout', 'completeDetails'); } return $restView->with('cartContent', $cartContent)->with("breadcrumbParam", $breadcrumbParam)->with("restaurant_header", $restaurantHeader); }
public function CartInfo() { if (Request::ajax()) { $cart = new CartController(); $products = $cart->getProduct(); $total = $cart->subTotalPrice($products); /* Kich thuoc sản pham thoi trang thành array */ foreach ($products as $product) { if (str_contains($product->size, ",")) { $array = explode(",", $product->size); $product->size = $array; } } return view("pages.customerInfo.cart", compact("products", "total")); } else { return redirect()->route("home"); } }
public function Finish(Request $request) { if (Auth::check() && Session::has("cart")) { $payment_method = (int) $request->get("method"); $cart = new CartController(); $products = $cart->getProduct(); $subTotal = $cart->subTotalPrice($products); $discounted = 0; //phan tram dc giam if (Session::has("codeDiscount")) { $code = Session::get("codeDiscount"); $discounted = DiscountCode::changeCodeToPercent($code); $total = $cart->totalPrice($subTotal, null, $code); } else { $total = $cart->totalPrice($subTotal, null, null); } $customerID = Auth::user()->id; $customerInfoID = Auth::user()->default_info_id; /* Status : * 1: done * 2:chua thanh toan * 3: moi */ $bill = Bill::create(["total" => $total, "customer_id" => $customerID, "customer_info_id" => $customerInfoID, "status" => 3, "payment_method" => $payment_method, "discounted" => $discounted]); $billID = $bill->id; foreach ($products as $item) { $price = $item->price * (100 - $item->percent) / 100; //don gia billDetail::create(["bill_id" => $billID, "products_id" => $item->id, "price" => $price, "amount" => $item->so_luong]); $count = Products::select(["count"])->where("id", $item->id)->first(); // so luong da~ bán $count->count += $item->so_luong; Products::where("id", $item->id)->update(["count" => $count->count]); //update so luong } /*Xoa discound code*/ if (Session::has("codeDiscount")) { $code = Session::get("codeDiscount"); DiscountCode::deleteCode($code); Session::forget("codeDiscount"); } /* Xoá cart */ Session::forget("cart"); /*Send mail*/ $this->sendMail($billID); /**********/ return redirect()->route("thanhtoan.thongtin.hoadon", $billID); } else { return redirect()->route("home"); } }