Example #1
0
 public function store(OrderRequest $request)
 {
     $order = $request->all();
     $order['user_id'] = Auth::id();
     Order::create($order);
     return Redirect::to("/?timer=true");
 }
Example #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(\App\Http\Requests\OrderRequest $request, $id)
 {
     $order = $this->orders->find($id);
     $order->update($request->except('_token', '_method'), $order->id);
     if ($order->status == 'processing') {
         return redirect('products');
     } elseif ($order->status == 'closed') {
         return redirect('orders/viewOpenOrders');
     }
 }
 /**
  * Update an existing orderline
  *
  * @param  OrderRequest $request The HTTP request
  * @return response
  */
 public function update(OrderRequest $request)
 {
     $user = Auth::user();
     $order = $user->orders()->where('status_id', 1)->firstOrFail();
     $orderLine = $order->orderlines()->where('product_id', $request->input('product_id'))->first();
     if (!$orderLine->count()) {
         abort(500);
     }
     $orderLine->amount = $request->input('amount');
     if (!$orderLine->save()) {
         abort(500);
     }
     return redirect('bestelling');
 }
 public function store(Order $order, OrderRequest $request)
 {
     if (!$order->isAuthorized()) {
         return redirect(route('orders.show', [$order->id]))->with('error', 'You cant add products to that order');
     }
     DB::transaction(function () use($order, $request) {
         $id = $request->get('product_id');
         $quantity = $request->get('quantity');
         $order->products()->attach([$id => ['quantity' => $quantity]]);
         //todo increase same
         if ($order->status != 1) {
             $product = Product::find($id);
             $product->update(['quantity' => $product->quantity - $quantity]);
         }
     });
     return redirect(route('orders.edit', [$order->id]))->with('success', 'Product successfully added');
 }
Example #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(OrderRequest $request)
 {
     $user_id = '1';
     $input = $request->all();
     $order = new Order();
     $order->supplier_id = $input['supplier_id'];
     $order->created_by = $user_id;
     $order->save($request->all());
     for ($i = 0; $i < count($input['item_id']); $i++) {
         $order_detail = new OrderDetail();
         $order_detail->item_id = $input['item_id'][$i];
         $order_detail->item_description = $input['item_description'][$i];
         $order_detail->quantity = $input['quantity'][$i];
         $order_detail->price = $input['price'][$i];
         $order->order_details()->save($order_detail);
     }
     return redirect('/orders');
 }
Example #6
0
 public function placeOrder(OrderRequest $request)
 {
     //get session id
     $sessionId = session()->getId();
     //get cart session
     $sessionCart = $this->sessionCartRepo->getCartBySessionId($sessionId);
     $cartTotals = $this->sessionCartRepo->calculateTotalBySessionId($sessionCart);
     //add cart session in the orders table
     $cartData = ['session_id' => $sessionId, 'transportFee' => $cartTotals['transportFee'], 'total' => $cartTotals['total']];
     //get orders table id
     $order = $this->orderRepo->create($cartData);
     //add order info info
     $orderInfo = $this->orderInfoRepo->create($request->all());
     $order->info()->save($orderInfo);
     $this->notifications->sendOrderEmailToCustomer($order, $cartTotals);
     $this->notifications->sendOrderEmailToAdmin($order, $cartTotals);
     //generate a new session id
     session()->regenerate();
     //instead of response we will redirect to thank you page
     return response()->json(['success' => route('front.get.thankYou')]);
 }
Example #7
0
 public function handle(Requests\OrderRequest $request, Product $product, $id)
 {
     $product = $product->where('id', $id)->first();
     if ($product !== null) {
         $quantity = 1;
         if ($product->countable == true) {
             $quantity = $request->get('quantity');
         }
         // TODO вынести обработку steam id в отдельный класс или в Request
         // Нужно полученый STEAM ID проверить в зависимости от игры
         $steam_id = $request->get('steam_id');
         $server = Server::where('id', $product->server_id)->first();
         switch ($server->engine) {
             case 1:
                 if (preg_match("/\\[U:1:(\\d+)\\]/", $steam_id)) {
                     $steam_id = preg_replace("/\\[U:1:(\\d+)\\]/", "\$1", $steam_id);
                     $A = $steam_id % 2;
                     $B = intval($steam_id / 2);
                     $steam_id = "STEAM_0:" . $A . ":" . $B;
                 }
                 break;
         }
         //=======
         $order = new Order();
         $order->product_id = $product->id;
         $order->quantity = $quantity;
         $order->sum = intval($product->discount_price * $quantity);
         $order->email = $request->get('email');
         $order->steam_id = $steam_id;
         $order->status = 0;
         $order->save();
         $payment = new Payment(config('robokassa.login'), config('robokassa.paymentPassword'), config('robokassa.validationPassword'));
         $payment->setInvoiceId($order->id)->setSum($order->sum)->setDescription('Покупка ' . $product->title);
         return redirect($payment->getPaymentUrl());
     }
     return redirect()->route('shop.index');
 }
Example #8
0
 public function apply(Requests\OrderRequest $request)
 {
     $order = $request->except('_token');
     $cartData = \App\Cart::find($order['cartCode']);
     $ip = $_SERVER['REMOTE_ADDR'];
     \App\Order::create(['name' => $order['name'], 'cart' => $cartData->data, 'email' => $order['email'], 'paytipe' => $order['payway'], 'address' => $order['zipcode'] . " " . $order['address'], 'ip' => $ip]);
     $cookie = shoppingCart::unsetCart();
     return redirect('/')->with('message', 'Ваша заказ принят к обработке')->withCookie($cookie);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(OrderRequest $request, $id)
 {
     //status_order
     if ($request->get('status_order') == true) {
         $status_order = 1;
     } else {
         $status_order = 0;
     }
     //amount_order
     $product = Product::find($request->get('product_id'));
     // $amount_order =$request->get('qty')*$product->price;
     $data = ['transaction_id' => $request->get('transaction_id'), 'product_id' => $request->get('product_id'), 'qty' => $request->get('qty'), 'note' => $request->get('note'), 'price_order' => $product->price, 'discount_order' => $product->discount, 'status_order' => $status_order];
     $order = Order::find($id);
     $order->update($data);
     $this->update_transaction($data['transaction_id']);
     //update amount transaction.
     return redirect()->route('order.index');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(OrderRequest $request, $id)
 {
     $order = Order::findOrFail($id);
     $order->update($request->all());
     return redirect('orders');
 }
Example #11
0
 public function getDataAOrder(OrderRequest $request)
 {
     $order = new Order();
     return json_encode($order->viewOrder($request->input('id')));
 }
Example #12
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(OrderRequest $request, $id)
 {
     try {
         if ($request->hasFile('file')) {
             $fileInfo = $this->uploadFile($request->file('file'), 'orders');
             if ($fileInfo) {
                 $this->order->update($id, $request->only($this->dataGet), $fileInfo['name']);
             }
         } else {
             $this->order->update($id, $request->only($this->dataGet));
         }
         return redirect()->back();
     } catch (Exception $e) {
         return redirect()->back()->withInput()->with('error', 'Không thể truy vấn dữ liệu');
     }
 }
 public function addOrder(OrderRequest $request)
 {
     $checkout = $request->all();
     $data = Session::get('cart');
     $orderid = Order::addOrder($checkout, $data);
     foreach ($data as $key) {
         # code...
         Order_detail::addOrder_detail($orderid, $key);
     }
     Session::forget('cart');
     return redirect('/cart')->withErrors(['error' => 'Vui lòng kiểm tra email để xác nhận đơn hàng']);
 }
Example #14
0
 public function update(OrderRequest $request, $id)
 {
     DB::transaction(function () use($request, $id) {
         $data = $request->all();
         $model = Order::find($id);
         $status = $request->status;
         if ($status == "Cancelled") {
             $products = OrderDetail::where('orderID', $id)->get();
             foreach ($products as $item) {
                 $product = Product::find($item['productID']);
                 $qty = DB::table("OrderDetail")->where('orderID', $item['orderID'])->where('productID', $item['productID'])->first()->pQty;
                 $product->number += $qty;
                 $product->purchase -= $qty;
                 $product->save();
             }
         }
         $model->status = $status;
         $model->save();
     });
     DB::commit();
     return redirect(URL::to("/") . "/admin/order/" . $id . "/edit")->withSuccess(Lang::get('messages.update_success'));
 }