當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Order::whereId方法代碼示例

本文整理匯總了PHP中app\Order::whereId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Order::whereId方法的具體用法?PHP Order::whereId怎麽用?PHP Order::whereId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Order的用法示例。


在下文中一共展示了Order::whereId方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($orderId)
 {
     $order = Order::whereId($orderId)->select('id', 'type')->first();
     $user = \Auth::user();
     if ($user) {
         //If a user is not trusted, send the error. Avoiding direct access routes to action by invalid user
         if (!$user->isTrusted()) {
             return redirect()->route('orders.show_cart', [$order->id])->withErrors(trans('freeproduct.unauthorized_access'));
         }
         //You can create free product from a sort order cart or wish list
         if ($order->type != 'cart' && $order->type != 'wishlist') {
             return redirect()->route('orders.show_cart', [$order->id])->withErrors(trans('freeproduct.order_type_invalid'));
         }
         //As is authorized to create, I check order detail
         $order_content = OrderDetail::where('order_id', $order->id)->get();
         //Sumatorial the total order to validate that the free product creator has enough points for the transaction
         $total_points = 0;
         foreach ($order_content as $orderDetail) {
             $product = Product::whereId($orderDetail->product_id)->select('id', 'price')->first();
             $total_points += $orderDetail->quantity * $product->price;
         }
         if ($user->current_points < $total_points) {
             return redirect()->route('orders.show_cart')->withErrors(['main_error' => [trans('store.cart_view.insufficient_funds')]]);
         }
         $jsonOrder = json_encode($order_content->toArray());
         $panel = $this->panel;
         return view('freeproducts.create', compact('jsonOrder', 'panel', 'orderId'));
     } else {
         return redirect()->route('products')->withErrors(trans('freeproduct.unauthorized_access'));
     }
 }
開發者ID:ant-vel,項目名稱:antVel,代碼行數:36,代碼來源:FreeProductsController.php

示例2: getOrderCancel

 public function getOrderCancel($id, Order $order, Payment $payment)
 {
     $customer_order = $order->whereId((int) $id)->first();
     $amount = $customer_order->order_amount;
     $customer_id = $customer_order->customer_id;
     $delete = $order->whereId((int) $id)->delete();
     if ($delete) {
         //            ->increment('votes', 5);
         $payment->where('customer_id', (int) $customer_id)->increment('account_balance', $amount);
         flash()->success('Order #' . $id . ' has been cancelled and ' . nairaFormater($amount) . ' refunded to ' . customerFullname($customer_id) . '!');
     } else {
         flash()->error('An error occurred while cancelling Order #' . $id . '!');
     }
     return redirect()->back();
 }
開發者ID:BarkaBoss,項目名稱:TheHex,代碼行數:15,代碼來源:OrderController.php

示例3: destroy

 public function destroy($id)
 {
     $order = Order::whereId($id)->firstOrFail();
     $order->delete();
     return redirect('/order/index')->with('status', 'The selected order has been deleted');
 }
開發者ID:jakzaizzat,項目名稱:KopiBean,代碼行數:6,代碼來源:.OrdersController.php

示例4: delete

 public function delete(Request $request)
 {
     $order = Order::whereId($request->id)->first();
     foreach ($order->events as $event) {
         $event->delete();
     }
     $order->event()->delete();
     return Order::whereId($request->id)->delete();
 }
開發者ID:znittzel,項目名稱:datianew,代碼行數:9,代碼來源:OrderController.php


注:本文中的app\Order::whereId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。