public function postIndex(Request $request) { $cart = new Cart(); $prescription = NULL; if ($request->hasFile('prescription')) { $file = $request->file('prescription'); $request->file('prescription')->move('uploads', $file->getClientOriginalName()); $prescription = $file->getClientOriginalName(); } $order = new Order(); $order->fullname = $request->fullname; $order->email = $request->emailaddress; $order->address = $request->address; $order->mobile = $request->mobile; $order->prescription = $prescription; $order->save(); for ($i = 0; $i < count($request->product_id); $i++) { $orderItem = new OrderItem(); $orderItem->order_id = $order->id; $orderItem->product_id = $request->product_id[$i]; $orderItem->quantity = $request->quantity[$i]; $orderItem->save(); } $order_details = Order::find($order->id); $data = array('order_details' => $order_details, 'total' => $cart->getTotal(), 'fullname' => $request->fullname, 'emailaddress' => $request->emailaddress); Mail::send('emails.order', ['data' => $data], function ($m) use($data) { $m->from('*****@*****.**', 'EMarket'); $m->to($data['emailaddress'], $data['fullname'])->subject('Order Placed Successfully'); }); $cart->clear(); return redirect('checkout/placed/' . $order->id); }
public function getShow() { $cart = new Cart(); $data = array('contents' => $cart->items(), 'total' => $cart->getTotal()); return view('subview/cart', $data); }
/** * Bootstrap any application services. * * @return void */ public function boot() { $cart = new Cart(); view()->share('categories', tbl_categories::all()); view()->share('cart_count', $cart->count()); }
public function removeCart() { $cart = new Cart(); $cart->clear(); return Response::json(array('success' => true, 'message' => 'All items in cart has been remove.')); }