public function address(Request $request) { //dd($request); $order = new Orders(); $order->sity = $request->sity; $order->province = $request->province; $order->postcode = $request->postcode; $order->street1 = $request->street1; $order->street2 = $request->street2; $order->firstname = $request->firstname; $order->lastname = $request->lastname; $order->phone = $request->phone; $order->email = $request->email; $order->shipping_method = $request->shipping_method; $order->payment = $request->payment; $order->total_price = $request->total_order; // dd($request->product); $order->save(); $order_id = $order->id; $product_id = $request->product; foreach ($product_id as $id) { $orderproduct = new OrderProduct(); $orderproduct->orders_id = $order_id; $orderproduct->product_id = $id; $orderproduct->save(); } $request->session()->forget('cart'); return redirect()->route('home'); }
public function checkOut(Request $request) { $order = new Orders(); $order->products = $request->input('products'); $order->user_id = $request->input('user'); $order->user_name = $request->input('userName'); $order->nomer = $request->input('nomer'); $order->shipment_office = $request->input('shipment-office'); $order->price = $request->input('price'); $order->status = $request->input('status'); $order->save(); Cart::destroy(); return redirect('profile/' . $request->input('user') . '/orders'); }
public function updateapproved($id) { $order = Orders::findOrFail($id); $order->status = 1; $order->update(); return redirect('orders'); }
public function store(FormBuilder $formBuilder, Request $request) { $form = $formBuilder->create(OrdersForm::class); // It will automatically use current request, get the rules, and do the validation if (!$form->isValid()) { return redirect()->back()->withErrors($form->getErrors())->withInput(); } Orders::create($request->all()); return redirect()->route('order.index'); }
public function getlist() { $order_list = Orders::all(); return Datatables::of($order_list)->addColumn('action', 'action here')->addColumn('fullname', function ($order_list) { $fullname = $order_list->firstname . " " . $order_list->lastname; return $fullname; })->addColumn('address', function ($order_list) { $address = $order_list->street1 . ", " . $order_list->province . ", " . $order_list->sity; return $address; })->make(true); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show() { //return view('user.profile', ['user' => User::findOrFail($id)]); if (\Auth::check()) { $id = \Auth::user()->id; $orders = Orders::where('user_id', '=', "1")->get(); $orders = Orders::all(); //$one = Orders::where('user_id', '=', $id)->first(); //return view('orders', compact('orders')); //return $one; return view('orders', ['orders' => $orders, 'id' => $id]); // return view('orders', ['orders' => $orders,'id' => $id ]); } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { if (\Auth::user()) { $order = \Auth::User()->orders(); $ids = null; if ($order) { $orders = Orders::where('cust_id', \Auth::User()->id)->get(); } $orders = Orders::where('cust_id', \Auth::User()->id)->where('order_id', $id)->get(); $i = 0; foreach ($orders as $order) { $order['p_name'] = Products::where('id', $order->product_id)->value('p_name'); $order['price'] = Products::where('id', $order->product_id)->value('price'); $ids[$order['product_id']] = $order['product_id']; } return view('pages.order', compact('orders'), compact('ids')); } else { return redirect('auth/login'); } }
public function persistOrder(Request $request, Response $response, $requestBody, $user) { DB::transaction(function () use(&$response, &$requestBody, &$user) { $deliveryInfo = new \stdClass(); $deliveryInfo->email = $requestBody->email; $deliveryInfo->phone = $requestBody->phone; $deliveryInfo->address = $requestBody->address; $baseOrderEntry = null; foreach ($requestBody->products as $product) { $createdEntry = Orders::create(["user_id" => $user->id, "product_id" => $product->id, "order_date" => date("Y-m-d H:i:s"), "delivery_date" => date("Y-m-d H:i:s"), "is_payed" => 0, "delivery_info" => json_encode($deliveryInfo, JSON_UNESCAPED_UNICODE), "in_order_with" => $baseOrderEntry !== null ? $baseOrderEntry->id : 0, "order_count" => $product->quantity]); if ($baseOrderEntry === null) { $baseOrderEntry = $createdEntry; } } $response->header("Content-Type", "application/json"); $response->header(Constants::RESPONSE_HEADER, "Successfully persisted entity."); $response->setStatusCode(Response::HTTP_CREATED); }); return $response; }
/** * Update the deadline date for an order. * * @author Sinthujan G. * @return mixed */ public function UpOrdDD() { $dets = array('orderID' => Request::input('ordID'), 'deadline' => Request::input('ddMask')); $ordD = DB::table('orders')->select('DueDate')->where('ordID', '=', $dets['orderID'])->first(); $messages = ['after' => 'The deadline must be a date after today or today.']; $rules = array('orderID' => 'required', 'deadline' => 'required|date_format:Y-m-d|after:today|before:' . $ordD->DueDate); // doing the validation, passing post data, rules and the messages $validator = Validator::make($dets, $rules, $messages); if ($validator->fails()) { // send back to the page with the input data and errors return Redirect::to('ArtAsDead')->withInput()->withErrors($validator); } else { $res = Orders::where('ordID', $dets['orderID'])->update(['DLineDate' => $dets['deadline']]); // if (!$res) MySQL ignores if same data is sent for update : resolve by writing a class and use this. // App::abort(500, 'Some Error'); return Redirect::to('ArtAsDead')->with('success', true)->with('message', 'Date successfully assigned'); } }
public function generateOrderId() { $orders = Orders::orderBy('id', 'desc')->first(); $newOrderId = $orders->order_id + 1; return $newOrderId; }
public function UpdOrderStat($ordID) { Orders::where('ordID', $ordID)->update(['status' => 'Completed']); return Redirect::to('/ArtMainOrders'); }
public function uploadslip(Request $request) { $rules = array('payment_slip' => 'required|mimes:jpeg,bmp,png,jpg,gif', 'orders_number' => 'required', 'payment_channel' => 'required', 'payment_price' => 'required', 'payment_date' => 'required', 'payment_time' => 'required'); $validator = \Validator::make($request->all(), $rules); if ($validator->fails()) { return redirect()->intended('/member')->withErrors(array('error' => 'โปรดตรวจสอบข้อมูลใหม่อีกครั้ง')); } $now = Carbon::now('Asia/Bangkok'); $hash = md5($now); $user = \Auth::user(); $imageName = $hash . '-' . $user->id . '.' . $request->file('payment_slip')->getClientOriginalExtension(); $request->file('payment_slip')->move(base_path() . '/public/images/slip/', $imageName); $link = '/images/slip/' . $imageName; $slip = Orders_slip::create(['payment_slip' => $link, 'orders_number' => $request->input('orders_number'), 'payment_channel' => $request->input('payment_channel'), 'payment_price' => $request->input('payment_price'), 'payment_date' => $request->input('payment_date'), 'payment_time' => $request->input('payment_time'), 'created_at' => $now, 'updated_at' => $now]); if ($slip->id == null) { return redirect()->intended('/member')->withErrors(array('error' => 'ยืนยันการชำระเงินผิดพลาด กรุณาลองใหม่อีกครั้ง')); } $order = Orders::where('orders_number', $request->input('orders_number'))->get()->first(); $order->status = 2; $order->updated_at = $now; $order->orders_slip = $slip->id; $result = $order->save(); if ($result) { $this->sendmail($order, $link, $slip); } //save notify $notify = new Notifications(); $notify->members_id = \Auth::user()->id; $notify->type = "PAYMENT_CONFIRM"; $notify->status = 0; $notify->created_at = $now; $notify->updated_at = $now; $notify->order_id = $order->id; $notify->message = "You have a new confirm payment !"; $notify->save(); return redirect()->intended('/member'); }
public function confirmOrders(Request $request, $id) { Orders::where('id', $id)->update(['status' => $request->input('shipment-office')]); return redirect()->back()->with($request->session()->flash('admin-success', 'Поръчката беше одобрена.')); }
/** * @param Request $request * @param $order_id * @return $this */ public function order_details(Request $request, $order_id) { $orders = Orders::where('order_id', $order_id)->get(); if ($request->user()->id == $orders->first()->author_id) { $products = array(); $quantities = array(); foreach ($orders as $order) { $products[] = Products::where('id', $order->product_id)->first(); $quantities[] = $order->quantity; } $categories = Categories::all(); return view('cart.details')->withProducts($products)->withQuantities($quantities)->withCategories($categories); } else { return redirect('/')->withErrors('You have not sufficient permissions'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Orders::destroy($id); return redirect('orders'); }
public function edit(Request $request) { $validator = Validator::make($request->all(), ['orders_number' => 'required']); if ($validator->fails()) { return Response::json(array('result' => false, 'data' => 'Some parameter not found.')); } $order = Orders::where('orders_number', $request->input('orders_number'))->get()->first(); if (!$order) { return Response::json(array('result' => false, 'data' => 'Order is empty.')); } $order->post_number = $request->input('post_number') == "" ? null : $request->input('post_number'); $order->updated_at = Carbon::now('Asia/Bangkok'); if ($order->save()) { return Response::json(array('result' => true, 'data' => $order, 'message' => 'Update id ' . $order->orders_number . ' updated.')); } return Response::json(array('result' => false, 'message' => 'Update has been error.')); }
public function index() { $orders = Orders::all(); return view('admin.order.index', compact('orders')); }
return response()->json(array(['cem' => $orders[0]->cem, 'borc' => $orders2[0]->purchase])); }); Route::get('/YoxlanishEt', function () { $CustomerID = Input::get('CustomerID'); $Date = Input::get('Date'); $Date2 = Input::get('Date2'); $subcate = \App\Orders::where('CustomerId', '=', $CustomerID)->get(); $sumborc = DB::select('select sum(borc) as cemborc from purchases where customerID = ? and created_at BETWEEN ? And DATE_SUB(?, INTERVAL 1 DAY)', array($CustomerID, '0000-00-00', $Date)); $orders = DB::select('select Borc ,Purchase,created_at from purchases where customerID = ? and created_at BETWEEN ? And ?', array($CustomerID, $Date, $Date2)); return Response::json($orders); }); Route::get('/YoxlanishEt2', function () { $CustomerID = Input::get('CustomerID'); $Date = Input::get('Date'); $Date2 = Input::get('Date2'); $subcate = \App\Orders::where('CustomerId', '=', $CustomerID)->get(); if ($Date == $Date2) { $sumborc = DB::select('select IFNULL(sum(borc)-sum(Purchase),0) as cemborc from purchases where customerID = ? and created_at BETWEEN ? And ?', array($CustomerID, '0000-00-00', $Date2)); } else { $sumborc = DB::select('select sum(Borc)-sum(Purchase) as cemborc from purchases where customerID = ? and created_at BETWEEN ? And DATE_SUB(?, INTERVAL 1 DAY)', array($CustomerID, '0000-00-00', $Date)); } return Response::json($sumborc); }); Route::get('/CategoryId', function () { $CategoryId = Input::get('CategoryId'); $Products = Products::where('CategoryId', '=', $CategoryId)->get(); return Response::json($Products); }); Route::get('/Product', function () { $id = Input::get('id'); $Products = Products::where('id', '=', $id)->get();
public function showInvoice(Request $request) { $rules = array('order' => 'required'); $validator = \Validator::make($request->all(), $rules); if ($validator->fails()) { return Response::json(array('result' => false, 'data' => 'กลับไปที่หน้าแรก โปรดตรวจสอบข้อมูลใหม่อีกครั้ง')); } $order = Orders::where("orders_number", $request->input('order'))->get()->first(); $orders_detail = Orders_detail::where("orders_number", $order->orders_number)->get(); $point_total = 0; $amount_total = 0; foreach ($orders_detail as $key => $value) { # code... $pro = DB::table('products_vol')->join('products', 'products.id', '=', 'products_vol.products_id')->where('products_vol.code', $value->product_vol_code)->first(); $value->product_name = $pro->name; $value->point = $pro->point; $point_total += $value->point * $value->product_vol_qty; $amount_total += $value->product_vol_qty; //product_vol_qty } $point_total = $point_total + ($amount_total - 1); // $total_grand = $request->input('total') + $request->input('trans'); // $user = array('name'=>$request->input('name') , 'address' => $request->input('address') // , 'phone'=>$request->input('phone') , 'trans' => $request->input('trans')); // $order = array('total'=>$request->input('total') , 'trans'=>$request->input('trans') , 'total_grand'=> $total_grand); return view('order.invoiceview', ['orders_detail' => $orders_detail, 'order' => $order, 'point_total' => $point_total]); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $id = \Auth::user()->id; $orders = Orders::where('user_id', '=', $id)->get(); return view('home', ['orders' => $orders]); }
public function delete_order(Request $request) { Orders::where('order_id', '=', $request->order_id)->delete(); return "ok"; }