/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function callback(Request $request) { parse_str(base64_decode(strtr($request->get('data'), array('-' => '+', '_' => '/'))), $params); $order = Order::findOrFail($params['orderid']); $order->setStatus(Config::get('paysera.statuses.' . $params['status'])); return 'OK'; }
/** * Merge the orders of a guest with an existing user order * @param [type] $orderID [description] * @param [type] $sessionID [description] * @return bool */ public function mergeOrders($orderID, $sessionID, $request) { $sessionOrder = Order::findOrFail($sessionID); $sessionOrderLines = $sessionOrder->orderlines()->get(); $userOrder = Order::find($orderID); $userOrderLines = $userOrder->orderlines()->get(); if (count($sessionOrderLines)) { foreach ($sessionOrderLines as $sessionOrderLine) { if (count($userOrderLines)) { foreach ($userOrderLines as $userOrderLine) { if ($userOrderLine->product_id == $sessionOrderLine->product_id) { $userOrderLine->amount = $sessionOrderLine->amount; $userOrderLine->save(); $sessionOrderLine->delete(); } else { $sessionOrderLine->order_id = $orderID; $sessionOrderLine->save(); } } } $sessionOrderLine->order_id = $orderID; $sessionOrderLine->save(); } } $guest = User::find($request->session()->get('user_id')); $guest->delete(); $sessionOrder->delete(); $request->session()->put('order_id', $orderID); $request->session()->forget('user_id'); return true; }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $order = Order::findOrFail($id); $categories = Category::all(); $products = Product::where('category_id', '=', $categories[0]->id)->get(); return view('order.show', compact('order', 'categories', 'products')); }
public function destroy($id) { $order = Order::findOrFail($id); $deleted = $order->delete(); $message = $deleted ? 'Pedido eliminado correctamente!' : 'El Pedido NO pudo eliminarse!'; return redirect()->route('admin.order.index')->with('message', $message); }
/** * Update the specified resource in storage. * * @param int $id * * @return Response */ public function update($id, Request $request) { $order = Order::findOrFail($id); $order->update($request->all()); Session::flash('flash_message', 'Order updated!'); return redirect('admin/orders'); }
public function destroy($id) { $order = Order::findOrFail(id); $deleted = $order->delete(); $message = $deleted ? "Pedido eliminado" : "Error al intentar eliminar el pedido"; return redirect()->route('admin.order.index')->with('message', $message); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $order = Order::findOrFail($id); $order_details = DB::table('order_details')->where('order_id', '=', $id)->get(); $supplier = Supplier::where('id', '=', $order->supplier_id)->firstOrFail(); $created_at = $order->created_at->format('Y M d'); return view('orders.single-order', compact('order', 'order_details', 'supplier', 'created_at')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { if (Auth::user()->admin == 1) { $order = Order::findOrFail($id); } else { $order = Order::where('group', Auth::user()->group)->where('id', $id)->firstOrFail(); } return view('order.show', ['order' => $order]); }
public static function makePayment($data) { try { Order::findOrFail($data['order_id'])->setStatus(Config::get('paysera.statuses.2')); $payment_data = ['projectid' => Config::get('paysera.projectid'), 'sign_password' => Config::get('paysera.sign_password'), 'currency' => Config::get('paysera.currency'), 'country' => Config::get('paysera.country'), 'test' => Config::get('paysera.test'), 'orderid' => $data['order_id'], 'amount' => intval($data['amount'] * 100), 'accepturl' => route('front.order.show', [$data['order_id']]), 'cancelurl' => route('front.order.show', [$data['order_id']]), 'callbackurl' => route('artme.paysera.callback', [])]; $request = WebToPay::redirectToPayment($payment_data, true); } catch (WebToPayException $e) { // handle exception } }
public function approveOrder(Request $request) { $order_id = $request->input('order_id'); $order = Order::findOrFail($order_id); try { event(new OrderWasApproved($order)); $order->confirmed = true; $order->save(); } catch (Card $e) { return response()->json(['success' => false, 'message' => 'Your card was declined, please try again.'], 402); } catch (Base $e) { return response()->json(['success' => false, 'message' => 'The transaction did not go through, please try again.'], 402); } catch (Authentication $e) { return response()->json(['success' => false, 'message' => 'The API key provided is wrong, please make sure that you are using the correct keys.'], 402); } return response()->json(['success' => true, 'message' => 'The card was successfully charged'], 200); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $user = Auth::User(); $cart = DB::table('orders')->select('id')->where('status_id', '=', 1)->where('user_id', '=', $user->id)->value('id'); $cartQuantity = DB::table('order_products')->where('order_id', '=', 40)->sum('quantity'); if ($cart == null) { $order = new Order(); $order->user_id = $user->id; $order->status_id = 1; $order->save(); } $items = Order::findOrFail($cart)->product()->get(); $sum = 0; foreach ($items as $item) { $sum += number_format($item->pivot->quantity * $item->price, 2); } return view('cart.index', ['items' => $items, 'sum' => $sum, 'user' => $user]); }
public function printReport(Request $request) { $this->data['reward'] = Price::all(); $this->data['company'] = $request->input('company'); $this->data['date_from'] = $request->input('date_from'); $this->data['date_to'] = $request->input('date_to'); foreach ($request->input('select') as $val) { $this->data['orders'][] = Order::findOrFail($val); $order = Order::findOrFail($val); if ($order->departure_order_type == 1) { $this->data['dep'][] = $order->departure_passengers * $this->data['reward'][0]->reward; } else { $this->data['dep'][] = $this->data['reward'][$order->departure_order_type - 1]->reward; } if ($order->arrivals_order_type == 1) { $this->data['arr'][] = $order->arrivals_passengers * $this->data['reward'][0]->reward; } else { $this->data['arr'][] = $this->data['reward'][$order->departure_order_type - 1]->reward; } } return $this->render('reports.print-report'); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // add authorize function to prevent user view other user's order $order = \App\Order::findOrFail($id); return view('orderdetail', compact('order')); }
public function declineOrder($id) { $order = Order::findOrFail($id); $order->decline(); return redirect()->to('panel/Orders'); }
function orderChangeStatus($order_id) { if ($order = \App\Order::findOrFail($order_id)) { if ($order->sent_flag == 1) { $order->sent_flag = 0; } else { $order->sent_flag = 1; } if ($order->save()) { return Redirect::back()->with('success', 'Status changed successfully.'); } else { return Redirect::back()->with('error', 'Unable to change status. Please try again.'); } } else { return redirect("admin/orders")->with('error', 'Unable to find the order. Please try again.'); } }
public function postSessionToken(Request $r, $id) { $token = $r->input('sessiontokenid'); $order = Order::findOrFail($id); $order->session_token = $token; $order->save(); $sum = 0; foreach ($order->foods as $food) { $quantity = $food->pivot->quantity; $sum += (double) $food->price * $quantity; } $sum = $sum * 100; $url = 'https://hackathon.halcom.com/MBillsWS/API/v1/transaction/sale'; // $url = 'http://localhost:8999/MBillsWS/API/v1/transaction/sale'; $api_key = 'aa10000023'; $session_token = '1144940534034647600'; $secret_key = 'aa10000023'; $nonce = 1234567890; $amount = $sum; $utc_ts = '2015-11-21T01:51:17+00:00'; $f = fopen('request.txt', 'w'); $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_VERBOSE => 1, CURLOPT_STDERR => $f, CURLOPT_SSL_VERIFYPEER => false)); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['apikey' => $api_key, 'amount' => $amount, 'currency' => 'EUR', 'sessiontoken' => $token, 'purpose' => 'Online payment', 'paymentreference' => 'SI0011072015', 'orderid' => $id, 'channelid' => 'eshop1', 'auth' => ['nonce' => $nonce, 'timestamp' => $utc_ts, 'id' => 'sessiontoken', 'authtoken' => hash('sha256', strval($nonce) . $utc_ts . $session_token . $secret_key)]])); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); $response = curl_exec($ch); curl_close($ch); // print "laskdfj"; // print $response; // return json_decode($response); return view('orders.invoice')->withFoods($order->foods)->withId($order->id); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Request $request) { $rp_arr = []; $user = \Auth::user(); if ($user->role->name != ('admin' or 'root')) { // Permission denied } else { $data = $request->json()->get('data'); $lookUpArr = []; for ($i = 0; $i < count($data); $i++) { /*$from = Carbon::parse($data[$i]['from']); $to = Carbon::parse($data[$i]['to']); $location_id = \App\Location::where('name', $data[$i]['location'])->first()['id']; \App\Order::where('from', $from)->where('to', $to)->where('location_id', $location_id)->delete();*/ $id = $data[$i]['id']; $order = \App\Order::findOrFail($id); array_push($lookUpArr, ['from' => $order->from, 'to' => $order->to, 'location_id' => $order->location_id]); \App\Order::destroy($id); } $lookUpArr = array_unique($lookUpArr, SORT_REGULAR); foreach ($lookUpArr as $value) { $from = Carbon::parse($value['from']); $to = Carbon::parse($value['to']); $location_id = $value['location_id']; $num_of_ordered = \App\Order::where('from', $from)->where('to', $to)->where('location_id', $location_id)->count(); $allowance = \App\Location::findOrFail($location_id)->capacity; if ($num_of_ordered < $allowance) { if ($num_of_ordered == 0) { array_push($rp_arr, ['from' => $value['from'], 'to' => $value['to'], 'status' => '-1']); } else { array_push($rp_arr, ['from' => $value['from'], 'to' => $value['to'], 'status' => '1']); } } else { array_push($rp_arr, ['from' => $value['from'], 'to' => $value['to'], 'status' => '0']); } } } return response()->json(['data' => $rp_arr]); }
/** * Update the specified resource in storage. Useful for confirming an order. So if an employee confirms an order, you should call this function. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $order = Order::findOrFail($id); $order->update(['state_id' => $request->get('state_id'), 'acquired_by' => Auth::user()->userable->id]); return redirect('/'); }
/** * AJAX запрос информации о заказе */ public function getViewOrder(Request $request) { // Обрабатываем только AJAX запрос if ($request->ajax()) { try { $order = Order::findOrFail($request->input('id')); //DESC Проверить доступ для пользователя } catch (Exception $e) { return response()->json(null, 404); } $res_order = array('id' => $order->id, 'ident' => $order->ident, 'created_at' => date("d.m.Y H:i", strtotime($order->created_at)), 'company' => Sentinel::findById($order->user_id)->company, 'phone' => Sentinel::findById($order->user_id)->phone, 'operator' => $order->oper->name, 'transfer_to_airport' => $order->order_to_airport, 'transfer_from_airport' => $order->order_from_airport, 'airport_departure' => $order->departure->airport, 'departure_time' => date("d.m.Y H:i", strtotime($order->departure_time)), 'departure_order_type' => $order->departure_order_type, 'departure_passengers' => $order->departure_passengers, 'arrivals_time' => date("d.m.Y H:i", strtotime($order->arrivals_time)), 'airport_arrivals' => $order->arrivals->airport, 'arrivals_order_type' => $order->arrivals_order_type, 'arrivals_passengers' => $order->arrivals_passengers, 'arrivals_flight_num' => $order->arrivals_flight_num, 'person_name' => $order->person->last_name . ' ' . $order->person->first_name . ' ' . $order->person->middle_name, 'person_phone' => $order->person->phone, 'person_passport' => $order->person->passport_num . ' выдан: ' . $order->person->passport_data . ' ' . $order->person->passport_issued, 'person_contact' => $order->phones, 'amount' => $order->amount, 'desc' => $order->comment, 'status' => $order->order_status); return response()->json($res_order); } else { return redirect()->back(); } }
/** * 支付回调 * @return [type] [description] */ public function feedback(Request $request, $aid, $oid = NULL) { $aid = $request->input('aid') ?: $aid; $oid = $request->input('oid') ?: $oid; $account = WechatAccount::findOrFail($aid); $api = new API($account->toArray(), $account->getKey()); $pay = new WechatPayTool($api); $result = $pay->notify(function ($result, &$message) use($account, $oid) { if ($result['return_code'] == 'SUCCESS') { $wechatUser = WechatUser::where('openid', $result['openid'])->firstOrFail(); $result = array_only($result, ['return_code', 'return_msg', 'mch_id', 'device_info', 'result_code', 'err_code', 'err_code_des', 'trade_type', 'bank_type', 'total_fee', 'fee_type', 'cash_fee', 'cash_fee_type', 'coupon_fee', 'coupon_count', 'transaction_id', 'out_trade_no', 'attach', 'time_end']); WechatBill::create($result + ['waid' => $account->getKey(), 'wuid' => $wechatUser->getKey()]); if (!empty($oid)) { //因为是微信访问的,只能靠记录日志来查询是否失败 $order = Order::findOrFail($oid); $order->pay($result['total_fee']); $this->dispatch((new \App\Jobs\OrderDeal($order))->delay(config('site.order.deal', 14 * 86400))); } } else { WechatBill::create(['return_code' => $result['return_code'], 'return_msg' => $result['return_msg'], 'waid' => $account->getKey()]); } return true; }); return $result; }
/** * 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'); }
/** * Удаление заказа */ public function postDeleteOrder(Request $request) { try { $order = Order::findOrFail($request->input('pk_id')); $order->delete(); } catch (Exception $e) { $this->SetErrorNotifyMessage('Ошибка выполнения операции.'); return redirect()->back(); } $this->SetSuccessNotifyMessage('Заказ успешно удален'); return redirect()->back(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $order = Order::findOrFail($id); $order->sweeties()->detach(); $order->delete(); }
public function editOrder(Request $request) { $userID = \Auth::user()->id; $user = User::find($userID); $orderID = $request->input('id'); // if User is Admin if (Bouncer::is($user)->an('admin')) { $order = Order::findOrFail($orderID); $order->status = $status; $order->method = $method; $order->shipment_fee = $shippingfee; $order->sub_total = $subtotal; $order->tax = $tax; $order->total = $total; $order->save(); } // if User Owns the Order if (\Bouncer::allows('edit-order', Order::class)) { $order = $user->orders()->find($orderID); $order->status = $status; $order->method = $method; $order->shipment_fee = $shippingfee; $order->sub_total = $subtotal; $order->tax = $tax; $order->total = $total; $order->save(); } }
public function doBack(Request $request, $order_id, $gateway) { $order = Order::findOrFail($order_id); $data = $request->all(); $order_id = str_pad($order_id, 8, '0', STR_PAD_LEFT); $amount = $order->amount; switch ($gateway) { case 'alipay': $omnipay = Omnipay::create('Alipay_Express'); if ($request->isMethod('post')) { $params = ['request_params' => $_POST]; } else { $params = ['request_params' => $_GET]; } $omnipay->setPartner(getenv('payment.alipay.partner')); $omnipay->setKey(getenv('payment.alipay.key')); $omnipay->setSellerEmail(getenv('payment.alipay.seller_email')); $response = $omnipay->completePurchase($params)->send(); if ($response->isSuccessful() && $response->isTradeStatusOk()) { $responseData = $response->getData(); if ($order['status'] === 'pending') { $order->gateway = $gateway; $order->transaction_id = $responseData['request_params']['trade_no']; $order->received = $responseData['request_params']['total_fee']; $order->status = 'processing'; } if ($request->isMethod('post')) { echo 'success'; } } else { if ($request->isMethod('post')) { return 'fail'; } } break; case 'paypal': $omnipay = Omnipay::create('PayPal_Express'); $amount = $this->xfee($this->xchange($amount), 0.044, 0.3); $params = ['transactionId' => $order['id'], 'amount' => $amount, 'currency' => 'USD']; $omnipay->setUsername(getenv('payment.paypal.user')); $omnipay->setPassword(getenv('payment.paypal.pass')); $omnipay->setSignature(getenv('payment.paypal.sign')); $omnipay->setTestMode(getenv('payment.paypal.test')); $response = $omnipay->completePurchase($params)->send(); $responseData = $response->getData(); if ($response->isSuccessful() && $responseData['PAYMENTINFO_0_ACK'] === 'Success') { if ($order['status'] === 'pending') { $order->gateway = $gateway; $order->transaction_id = $responseData['PAYMENTINFO_0_TRANSACTIONID']; $order->received = $this->xchange($responseData['PAYMENTINFO_0_AMT'] - $responseData['PAYMENTINFO_0_FEEAMT'], 'USDCNY'); $order->status = 'processing'; } } break; case 'unionpay': $omnipay = Omnipay::create('UnionPay_Express'); $params = ['request_params' => $_POST]; $omnipay->setMerId(getenv('payment.unionpay.partner')); $omnipay->setCertDir(getenv('payment.unionpay.certdir')); $response = $omnipay->completePurchase($params)->send(); $responseData = $response->getData(); if ($response->isSuccessful() && $responseData['respMsg'] === 'success') { if ($order['status'] === 'pending') { $order->gateway = $gateway; $order->transaction_id = $responseData['queryId']; $order->received = $responseData['settleAmt'] / 100; $order->status = 'processing'; } } break; case 'wechat': $omnipay = Omnipay::create('WechatPay'); $params = ['request_params' => file_get_contents('php://input')]; $omnipay->setAppId(getenv('payment.wechat.app_id')); $omnipay->setMchId(getenv('payment.wechat.partner')); $omnipay->setApiKey(getenv('payment.wechat.pay_sign_key')); $response = $omnipay->completePurchase($params)->send(); if ($response->isSuccessful() && $response->isPaid()) { $responseData = $response->getData(); if ($order['status'] === 'pending') { $order->gateway = $gateway; $order->transaction_id = $responseData['transaction_id']; $order->received = $responseData['total_fee']; $order->status = 'processing'; } if ($request->isMethod('post')) { echo '<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>'; } } else { if ($request->isMethod('post')) { return '<xml><return_code><![CDATA[FAIL]]></return_code></xml>'; } } break; default: return trans('message.unsupported_gateway'); } $order->save(); if ($request->isMethod('post') && $gateway != 'unionpay') { exit; } return view('order.details', ['order' => $order]); }
function orderExport($order_id) { if ($order = \App\Order::findOrFail($order_id)) { $data = array(); $items = $order->items; $cnt = 0; foreach ($items as $item) { $cnt++; $data[] = ['#' => $cnt, 'Order' => $order->name, 'Dealer' => $order->dealer_name, 'User' => $order->user->name, 'Manufacturer' => $order->manufacturer_name, 'Item code' => $item->product->code, 'Item name' => $item->name, 'Quantity' => $item->quantity, 'Price' => $item->price . "/-", 'Remarks' => $item->remarks, 'Dated' => date("d-m-Y", strtotime($order->created_at))]; } if (!empty($data)) { \Excel::create($order->name, function ($excel) use($data, $order) { $excel->sheet('Order - ' . date("F d, Y", strtotime($order->created_at)), function ($sheet) use($data) { $sheet->fromArray($data); }); })->export('xls'); } } else { return redirect("users/orders")->with('error', 'Unable to find the order. Please try again.'); } }
/** * Show the contents of a wish list * * @return view for orders.wish */ public function showWishList($id = '') { /** * Checking if there is a product in flashWishList, if so, it will be saved into the basic wish list. * This process happens just before the user add a product to wishlist being not logged. * flashWishList will be deleted after being used into addToOrder method */ if (Session::get('flashWishList') !== null) { $this->addToOrder('wishlist', Session::get('flashWishList.productId'), new Request()); Session::forget('flashWishList'); Session::save(); } //saving added to wishlist message (it happens when the product is added to wishlist, and the method call this one) Session::forget('suggest-listed'); if (Session::has('message')) { Session::push('message', Session::get('message')); } $user = \Auth::user(); $productsHelper = new productsHelper(); $suggestions = []; $hasWishList = true; $hasLaterCart = true; $wishListName = trans('store.basic_wish_list'); if ($user) { /** * it is used to verify whether the order required exist or not. * if the order exists, its content is returned, otherwise, * the basic wish list is retrieved * @var string */ $order = ''; /** * validating if there's a order requested. * if it fails, there will be an 404 exception threw */ try { $order = Order::findOrFail($id); } catch (ModelNotFoundException $e) { if (trim($id) != '') { throw new NotFoundHttpException(); } } //if the user requires a specific wish list, its details will be provided if ($order) { $cart = Order::ofType('wishlist')->with('details')->where('user_id', $user->id)->where('id', $order->id)->first(); /** * $wishListName will have the wish list name to be showed in the view * @var string */ $wishListName = $cart ? $cart->description : $wishListName; } else { $cart = Order::ofType('wishlist')->with('details')->where('user_id', $user->id)->first(); } /** * listing the user wish lists saved in his account. * if there was a specific wish list requiered, it will be excluded from the directory list */ $wishLists = Order::select(['id', 'user_id', 'description'])->ofType('wishlist')->with('details')->where('description', '<>', '')->where('user_id', $user->id)->where('id', '<>', $cart ? $cart->id : '')->take(5)->get(); //products list saved for later $laterCart = Order::ofType('later')->with('details')->where('user_id', $user->id)->first(); //evaluating wish list if ($cart) { if ($cart->details && $cart->details->count() > 0) { //saving the ids selected to not include them into suggestions. $productsHelper->setToHaystack($cart->details, 'product_id'); } else { $hasWishList = false; } } else { $hasWishList = false; } //evaluating wish list if ($laterCart) { if ($laterCart->details && $laterCart->details->count() > 0) { //saving the ids selected to not include them into suggestions. $productsHelper->setToHaystack($laterCart->details, 'product_id'); } else { $hasLaterCart = false; } } else { $hasLaterCart = false; } } else { return redirect()->route('/auth/login'); } $panel = ['center' => ['width' => '12']]; //suggestions based on cart content $suggestions = ProductsController::getSuggestions(['preferences_key' => Session::get('suggest-listed'), 'limit' => 4]); Session::forget('suggest-listed'); return view('orders.wish', compact('cart', 'user', 'panel', 'suggestions', 'cart', 'laterCart', 'wishLists', 'wishListName', 'hasWishList', 'hasLaterCart')); }
* register Links Route */ Route::group(['prefix' => 'link', 'as' => 'link.'], function () { Route::get('/', ['as' => 'index', 'uses' => 'LinkController@adminIndex']); Route::get('/create', ['as' => 'create', 'uses' => 'LinkController@create']); Route::post('/store', ['as' => 'store', 'uses' => 'LinkController@store']); Route::get('/delete/{link}', ['as' => 'delete', 'uses' => 'LinkController@delete']); Route::get('/edit/{link}', ['as' => 'edit', 'uses' => 'LinkController@edit']); Route::post('/edit/{link}', ['as' => 'update', 'uses' => 'LinkController@update']); }); }); /* * Created By Iman on 94/12/01 * Ajax Routs */ Route::group(['prefix' => 'ajax', 'as' => 'ajax.'], function () { Route::group(['prefix' => 'news', 'as' => 'news.'], function () { Route::post('/uploadSummernote', ['as' => 'uploadSummernote', 'uses' => 'NewsController@uploadSummernote']); Route::delete('/deleteSummernote', ['as' => 'deleteSummernote', 'uses' => 'NewsController@deleteSummernote']); }); }); Route::get('/home', 'HomeController@index'); Route::get('/test/{order_id}', function ($order_id) { $order = \App\Order::findOrFail($order_id); return view('email.order', compact('order')); }); Route::group(['prefix' => 'news', 'as' => 'news.'], function () { Route::get('/', ['as' => 'index', 'uses' => 'NewsController@index']); Route::get('/show/{news}', ['as' => 'show', 'uses' => 'NewsController@show']); }); });
public function removeOrder(Request $request, $id) { $order = Order::findOrFail($id); $data = $request->all(); $merch = Merchandiser::findOrFail($order['merchandiser_id']); if (!empty($data['trade_no']) && $data['trade_no'] === $order->trade_no) { if ($this->verify($data, $merch['pubkey'])) { if (in_array($order->status, ['refunded', 'cancelled'])) { $order->delete(); return $this->jsonFormat(null); } else { return $this->jsonFormat(null, 'Cannot delete this order', '405'); } } else { return $this->jsonFormat(null, 'Signature Invalid or timestamp expired', '403'); } } else { return $this->jsonFormat(null, 'trade_no not matched', '404'); } }
public function getFulfill(Request $request, $id) { //Admin only: marks order as (un-)fulfilled $order = Order::findOrFail($id); $order->fulfilled = !$order->fulfilled; $order->save(); return redirect('order/show'); }