本文整理汇总了PHP中app\Order::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::findOrFail方法的具体用法?PHP Order::findOrFail怎么用?PHP Order::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Order
的用法示例。
在下文中一共展示了Order::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callback
/**
* 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';
}
示例2: mergeOrders
/**
* 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;
}
示例3: show
/**
* 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'));
}
示例4: destroy
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);
}
示例5: update
/**
* 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');
}
示例6: destroy
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);
}
示例7: show
/**
* 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'));
}
示例8: show
/**
* 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]);
}
示例9: makePayment
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
}
}
示例10: approveOrder
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);
}
示例11: index
/**
* 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]);
}
示例12: printReport
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');
}
示例13: show
/**
* 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'));
}
示例14: declineOrder
public function declineOrder($id)
{
$order = Order::findOrFail($id);
$order->decline();
return redirect()->to('panel/Orders');
}
示例15: orderChangeStatus
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.');
}
}