当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::with方法代码示例

本文整理汇总了PHP中app\Order::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::with方法的具体用法?PHP Order::with怎么用?PHP Order::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Order的用法示例。


在下文中一共展示了Order::with方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Return all the orders with their products and price/amount at given time
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function index()
 {
     return Order::with(['products' => function ($query) {
         $query->select(['id', 'name', 'price', 'pivot.price', 'pivot.amount']);
         $query->orderBy('sort');
     }])->get();
 }
开发者ID:KassaKiosk,项目名称:management,代码行数:12,代码来源:OrdersController.php

示例2: edit

 public function edit($id)
 {
     $orders = Order::with('product')->where('order_unique_id', $id)->get();
     $products = Product::lists('product_name', 'id');
     $title = "Edit order ( {$id})";
     return view('order.edit', compact('orders', 'title', 'products', 'id'));
 }
开发者ID:ssi-anik,项目名称:lcrud,代码行数:7,代码来源:OrdersController.php

示例3: handle

 /**
  * Handle the event.
  *
  * @param  MadeCheckout  $event
  * @return void
  */
 public function handle(MadeCheckout $event)
 {
     $user = $event->user;
     $checkout = $event->checkout;
     $orders = Order::with('product')->where('checkout_id', $checkout->id)->get();
     $admin = Sentinel::findRoleBySlug('admin');
     $admins = $admin->users()->get();
     $admin_emails = [];
     foreach ($admins as $admin) {
         array_push($admin_emails, $admin->email);
     }
     $data = ['checkout' => $checkout, 'orders' => $orders, 'user' => $user];
     //dd($data);
     Mail::send('email.orderconfirmation', $data, function ($message) use($user) {
         $message->from('care@trolleyin.com', $name = "Trolleyin");
         $message->subject('Trolleyin.com Order Confirmation');
         $message->to($user->email);
     });
     foreach ($admin_emails as $email) {
         Mail::send('email.admin.orderconfirmation', $data, function ($message) use($email) {
             $message->from('admin@trolleyin.com');
             $message->subject('New Order Placed');
             $message->to($email);
         });
     }
 }
开发者ID:axicraw,项目名称:tropara,代码行数:32,代码来源:MailOrderConfirmation.php

示例4: belongToUser

 /**
  * Make sure order belong to user given.
  *
  * @param User  $user
  * @param Order $order
  *
  * @return bool
  */
 public function belongToUser(User $user, $order_id, &$order = null)
 {
     $query = Order::with('details')->where(['id' => $order_id, 'user_id' => $user->id])->first();
     if (func_num_args() > 1) {
         $order = $query;
     }
     return $query ? true : false;
 }
开发者ID:ant-vel,项目名称:antVel,代码行数:16,代码来源:OrderRepository.php

示例5: fire

 /**
  * Execute the console command.
  * updating status prepared to traveling
  * @return mixed
  */
 public function fire()
 {
     $orders = Order::with('user')->where('status', 3)->get();
     if ($orders) {
         foreach ($orders as $order) {
             $order->update(['status' => 4, 'shipped_on' => Carbon::now(), 'expected_delivery_on' => Carbon::now()->addDay()]);
             event(new OrderShippedOn($order));
         }
     }
 }
开发者ID:Tisho84,项目名称:laravel-work,代码行数:15,代码来源:TravelOrder.php

示例6: show

 /**
  * @param $id
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function show($id)
 {
     try {
         $order = Order::with('user', 'items.item')->findOrFail($id);
         return view('orders.show', compact('order'));
     } catch (ModelNotFoundException $ex) {
         Flash::error('Model not found');
         return view('orders.index');
     }
 }
开发者ID:namoosshah,项目名称:basketball,代码行数:14,代码来源:OrdersController.php

示例7: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $orders = Order::with('user')->where('status', 1)->whereNotNull('address_id')->get();
     if (count($orders)) {
         foreach ($orders as $order) {
             $order->update(['status' => 2, 'processed_on' => Carbon::now()]);
             event(new OrderWasProcessed($order));
         }
     }
 }
开发者ID:Tisho84,项目名称:laravel-work,代码行数:15,代码来源:ProcessOrder.php

示例8: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $orders = Order::with('user', 'address')->where('status', 4)->where('expected_delivery_on', '<', Carbon::now())->get();
     if ($orders) {
         foreach ($orders as $order) {
             $order->update(['status' => 5, 'delivered_on' => Carbon::now()]);
             event(new OrderWasDelivered($order));
         }
     }
 }
开发者ID:Tisho84,项目名称:laravel-work,代码行数:15,代码来源:DeliveredOrder.php

示例9: index

 public function index(Request $request)
 {
     //取出订单列表
     $builder = Order::with(['details'])->where('uid', '=', $this->user->getKey())->orderBy('updated_at', 'desc');
     if ($request->get('status')) {
         $builder->where('status', '=', $request->get('status'));
     }
     $this->_order_list = $builder->get();
     $this->_status = $request->get('status') ?: 0;
     return $this->view('m.ucenter');
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:11,代码来源:MemberController.php

示例10: getIndex

 public function getIndex()
 {
     $user_id = Auth::user()->id;
     $orders = Order::with('orderItems')->where('user_id', $user_id)->get();
     $order_count = $orders->count();
     foreach ($orders as $order) {
         $order->fullname = unserialize($order->fullname);
         $order->address = unserialize($order->address);
     }
     return view('/order', ['orders' => $orders, 'order_count' => $order_count]);
 }
开发者ID:starmatt,项目名称:webpapa,代码行数:11,代码来源:OrderController.php

示例11: index

 public function index()
 {
     dd(\Auth::user()->email);
     $user = \Auth::user();
     $member_id = \Auth::user()->id;
     // vibiraem vse zakazy usera
     $orders = \App\Order::with('orderItems')->where('member_id', '=', $member_id)->orderBy('created_at', 'desc')->get();
     // foreach ($orders as $order) {
     // 	dd($order->orderItems);
     // }
     return view('orders', compact('orders', 'user'));
 }
开发者ID:aleximillers,项目名称:estore-laravel-angular,代码行数:12,代码来源:OrderController.php

示例12: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $sortBy = Input::get('sortBy');
     $direction = Input::get('direction');
     $limit = Input::get('limit') ? Input::get('limit') : 20;
     $q = Input::get('q');
     /* 정렬이 있는경우 */
     if ($sortBy and $direction) {
         /*  정렬이 있고 검색이 있는 경우
          */
         //   $order = Order::whereHas('orderItem', function($query) use ($q){
         //     $query->where('product_code','LIKE',"%$q%");
         // })->with('orderItem')->orderBy($sortBy,$direction)->paginate($limit);
         $order = Order::whereHas('orderItem', function ($query) use($q) {
             $query->where('order_items.product_code', 'Like', "%{$q}%");
         })->with(['orderItem' => function ($query) use($sortBy, $direction) {
             $query->join('products', 'order_items.product_id', '=', 'products.id');
         }])->orderBy($sortBy, $direction)->paginate($limit);
         if ($q) {
             // /* 정렬이 있지만 검색은 없는경우
             // */
         } else {
             //$order = Order::with('orderItem')->orderBy($sortBy, $direction)->paginate($limit);
             $order = Order::with(['orderItem' => function ($query) use($sortBy, $direction) {
                 $query->leftJoin('products', 'order_items.product_id', '=', 'products.id')->get();
             }])->orderBy($sortBy, $direction)->paginate($limit);
         }
         //정렬이 없는 경우
     } else {
         /* 정렬은 없지만 검색이 있는 경우
          */
         if ($q) {
             $order = Order::whereHas('orderItem', function ($query) use($q) {
                 $query->where('order_items.product_code', 'Like', "%{$q}%");
             })->with(['orderItem' => function ($query) {
                 $query->join('products', 'order_items.product_id', '=', 'products.id');
             }])->orderBy('order_date', 'desc')->paginate($limit);
             //return dd($order);
         } else {
             $order = Order::with(['orderItem' => function ($query) {
                 $query->leftJoin('products', 'order_items.product_id', '=', 'products.id')->get();
             }])->orderBy('id', 'desc')->paginate($limit);
         }
     }
     //return dd($order);
     return view('order.index', compact('order'));
 }
开发者ID:sharpscar,项目名称:becomeus,代码行数:52,代码来源:OrderController.php

示例13: edit

 public function edit($id)
 {
     $order = Order::with(['details', 'order_express'])->join('order_expresses', 'order_expresses.id', '=', 'orders.id', 'INNER')->where('order_expresses.sid', $this->store->getKey())->find($id);
     if (empty($order)) {
         return $this->failure_noexists();
     }
     if ($order->order_express->express_type == 39) {
         $this->_express_address = UserAddress::find($order->order_express->uaid)->getFullAddressAttribute();
     } else {
         $user_stores = Store::with('user')->find($order->order_express->sid);
         $this->_express_address = $user_stores->name . '-店主:' . $user_stores->user->realname . '-电话:' . $user_stores->phone . '-地址:' . $user_stores->address ?: '无';
     }
     $keys = 'expresses_money';
     $this->_validates = $this->getScriptValidate('order.express', $keys);
     $this->_data = $order;
     return $this->view('store-backend.order.edit');
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:17,代码来源:OrderController.php

示例14: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $throwModelNotFound = function () {
         throw new ModelNotFoundException();
     };
     $router->model('admins', User::class, $throwModelNotFound);
     $router->model('users', User::class, $throwModelNotFound);
     $router->model('dispatchers', User::class, $throwModelNotFound);
     $router->model('drivers', User::class, $throwModelNotFound);
     $router->bind('orders', function ($id) {
         try {
             return Order::with('statusHistory')->findOrFail($id);
         } catch (Exception $e) {
             $this->throwModelNotFound();
         }
     });
 }
开发者ID:GiedriusQ,项目名称:taksistas,代码行数:24,代码来源:RouteServiceProvider.php

示例15: edit

 public function edit($id)
 {
     $order = Order::with(['order_express'])->where('fid', $this->factory->getKey())->find($id);
     if (empty($order)) {
         return $this->failure_noexists();
     }
     if ($order->order_express->express_type == 39) {
         $this->_user_address = UserAddress::find($order->order_express->uaid)->getFullAddressAttribute();
         $keys = 'express_name,no';
         $this->_validates = $this->getScriptValidate('order.deliver', $keys);
     } else {
         $this->_user_stores = User::find($order->uid)->stores()->get();
         $keys = 'sid';
         $this->_validates = $this->getScriptValidate('order.express_store', $keys);
     }
     $this->_data = $order;
     return $this->view('factory-backend.express.edit');
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:18,代码来源:ExpressController.php


注:本文中的app\Order::with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。