/** * Handle the event. * * @return void */ public function handle() { if (Cart::instance(auth()->id())->count(false) == 0) { } else { Cart::store(auth()->id()); } }
/** * Prepare global variables. * @return array */ public static function globalData() { if (!Auth::check()) { $rows = null; $cart = null; $grandTotal = null; } else { $rows = Cart::instance(auth()->id())->count(false); $cart = Cart::instance(auth()->id())->content(); $grandTotal = Cart::instance(auth()->id())->total(); } $data = array('menu' => self::getMenuData(self::$parent_id), 'header' => Setting::findOrFail(1), 'rows' => $rows, 'cart' => $cart, 'grand_total' => $grandTotal, 'currencies' => Currency::all()); return $data; }
public function destroyBooking() { Cart::instance('booking')->destroy(); }
/** * Returns the cart * * @return mixed */ public function getCart() { $cart = Cart::instance('checkout'); return $cart->content(); }
public static function destroy() { Cart::instance('cart')->destroy(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy() { $cart = Cart::instance('cartoon'); $cart->destroy(); return Response::json(array('result' => true, 'cart' => $cart->content(), 'count' => $cart->count())); }
/** * Clear shopping cart. * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function getDelete() { Cart::instance(auth()->id())->destroy(); return redirect('cart'); }
public function confirm(Request $request) { $now = new DateTime(); $rules = array('name' => 'required', 'address' => 'required', 'trans' => 'required', 'phone' => 'required'); $validator = \Validator::make($request->all(), $rules); if ($validator->fails()) { return Response::json(array('result' => false, 'data' => 'กลับไปที่หน้าแรก โปรดตรวจสอบข้อมูลใหม่อีกครั้ง', 'message' => $validator->messages()->all())); } //$validator->errors()->all() $order = new Orders(); $orders_number = $now->format("YmdHis") . '-' . \Auth::user()->id; $cart = Cart::instance('cartoon'); if ($cart->count() <= 0) { if ($validator->fails()) { return Response::json(array('result' => false, 'data' => 'กลับไปที่หน้าแรก โปรดตรวจสอบข้อมูลใหม่อีกครั้ง')); } } DB::beginTransaction(); try { $order->orders_number = $orders_number; $order->members_id = \Auth::user()->id; $order->members_name = $request->input('name'); $order->address = $request->input('address'); $order->phone = $request->input('phone'); $order->ems = $request->input('trans'); $order->total = $cart->total(); $order->total_grand = $cart->total() + $request->input('trans'); $order->created_at = Carbon::now('Asia/Bangkok'); $order->updated_at = Carbon::now('Asia/Bangkok'); $order->status = 1; $order->save(); DB::commit(); } catch (\Exception $e) { DB::rollBack(); return Response::json(array('result' => false, 'data' => 'ยืนยันผิดพลาด โปรดตรวจสอบข้อมูลใหม่อีกครั้ง', 'message' => $e)); } DB::beginTransaction(); try { $now = Carbon::now('Asia/Bangkok'); foreach ($cart->content() as $key => $item) { $pro = Products_vol::where('code', $item->id)->get()->first(); $orders_detail = new Orders_detail(); $orders_detail->orders_number = $order->orders_number; $orders_detail->product_vol_code = $item->id; $orders_detail->product_vol_name = $pro->name; $orders_detail->product_vol_qty = $item->qty; $orders_detail->product_vol_per = $pro->price; $orders_detail->created_at = $now; $orders_detail->updated_at = $now; $orders_detail->product_vol_price = $pro->price * $item->qty; $orders_detail->save(); DB::commit(); } } catch (\Exception $e) { DB::rollBack(); return Response::json(array('result' => false, 'data' => 'ยืนยันผิดพลาด โปรดตรวจสอบข้อมูลใหม่อีกครั้ง', 'message' => $e)); } $cart->destroy(); $this->sendmail($order); //save notify $notify = new Notifications(); $notify->members_id = \Auth::user()->id; $notify->type = "CREATE_ORDER"; $notify->status = 0; $notify->created_at = $now; $notify->updated_at = $now; $notify->order_id = $order->id; $notify->message = "You have a new order !"; $notify->save(); return Response::json(array('result' => true, 'data' => $order)); }
public function wishlistItemRemove($rowid) { Cart::instance(auth()->user()->id . 'wishlist')->remove($rowid); return redirect()->back(); }