本文整理汇总了PHP中app\models\Order::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::with方法的具体用法?PHP Order::with怎么用?PHP Order::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Order
的用法示例。
在下文中一共展示了Order::with方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$user = User::find($id);
$orders = Order::with('address')->where('user_id', $id)->orderBy('created_at', 'desc')->paginate(config('wyshop.page_size'));
// return $orders;
$order_status = config('wyshop.order_status');
return view('admin.order.index', ['orders' => $orders, 'order_status' => $order_status]);
}
示例2: callback
public function callback(Request $request)
{
$order = Order::with('payment')->where('sn', '=', $request->get('sn'))->firstOrFail();
$response = $order->payment->gateway->complete($order->createPurchaseOrder());
if ($order->payment->gateway->isSuccessful($response)) {
$order->pay($order->total_amount);
return redirect($request->getSession()->pull('payment_callback_redirect'));
} else {
throw new \Exception($response->getMessage());
}
}
示例3: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$order = Order::with('address', 'express', 'user', 'order_goods.good')->find($id);
foreach ($order->order_goods as $k => $v) {
if (!$v->good) {
unset($v->good);
$goods = Good::onlyTrashed()->find($v->good_id);
$order->order_goods["{$k}"]["good"] = $goods;
}
}
$order_status = config('wyshop.order_status');
return view('admin.order.edit', ['order' => $order, 'order_status' => $order_status]);
}
示例4: update
public function update(Request $request, $order_id, $id)
{
$order = Order::with('products')->findOrFail($order_id);
if (!$order->canEdit()) {
throw new \Exception('not_editable');
}
$quantity = $request->json()->get('quantity');
$new_order_products = [];
$updated_product = null;
foreach ($order->products as $index => $product) {
if ($product->id == $id) {
$product->quantity = $quantity;
$product->save();
$updated_product = $product;
}
$new_order_products[] = $product;
}
if ($updated_product) {
$order->calc($new_order_products);
$order->save();
return response()->updated($updated_product);
}
return response()->noContent();
}
示例5: getFinishedOrders
/**
* Get the last 8 finished orders
*
* @return array
*/
public function getFinishedOrders()
{
$orders = Order::with('products')->whereNotNull('finished')->take(8)->get();
return $this->prepareResponse($orders);
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$order = \App\Models\Order::with('products')->active()->first();
view()->share('order', $order);
return $next($request);
}
示例7: changeStatus
public function changeStatus($statusId, $orderId, $is_service = 0)
{
$response = 0;
try {
DB::transaction(function () use($statusId, $orderId, &$response, $is_service) {
$messageData = [];
$email = '';
if ($is_service) {
$order = ServiceOrder::with('user', 'service_status')->where('id', $orderId)->first();
$messageData['status_was'] = $order->service_status->status;
$order->service_status_id = $statusId;
$order->save();
$response = 1;
$email = $order->user->email;
$messageData['user'] = $order->user->name;
$messageData['type'] = 'прочие услуги';
$messageData['order_number'] = $order->id;
$messageData['status_now'] = ServiceStatus::find($statusId)->status;
} else {
if ($statusId == Order::CANCELED) {
$order = Order::with('products_in_order.price', 'user', 'status')->where('id', $orderId)->first();
foreach ($order->products_in_order as $product) {
$product->price->amount += $product->product_amount;
$product->price->save();
}
// $response = Order::CANCELED;
} else {
$order = Order::with('user', 'status')->where('id', $orderId)->first();
// if($statusId == Order::COMPLETED) {
// $response = Order::COMPLETED;
// } else {
// $response = 1;
// }
}
$messageData['status_was'] = $order->status->status;
$order->status_id = $statusId;
$order->save();
$response = 1;
$email = $order->user->email;
$messageData['user'] = $order->user->name;
$messageData['type'] = 'запчасти грузовых вагонов';
$messageData['order_number'] = $order->id;
$messageData['status_now'] = Status::find($statusId)->status;
}
Mail::send('emails.statusDone', $messageData, function ($message) use($email) {
$message->to($email)->subject('Смена статуса заказа');
});
});
} catch (Exception $e) {
$response = 0;
}
// dd($response);
echo $response;
}
示例8: obligation
public function obligation()
{
$obligation = Order::with('order_goods.good')->where('user_id', $this->user->id)->where('status', 0)->get();
// $index = array();
foreach ($obligation as $ob) {
$sum = 0;
foreach ($ob->order_goods as $k => $v) {
$sum += $v->good->price * $v->number;
}
$obligation["{$k}"]["xj"] = $sum;
// array_push($index,$sum);将得出的小计金额压入数组
}
// return $obligation;
return view('wechat.obligation', ['obligation' => $obligation]);
}
示例9: edit
public function edit($id)
{
$order = Order::with('address', 'express', 'user', 'order_goods.good')->find($id);
// return $order;
return view('admin.order.edit', ['order' => $order]);
}
示例10: getOrders
public static function getOrders()
{
$orders = Order::with('orderproduct.product')->get();
//print_r($orders);die();
return $orders;
}
示例11: edit
public function edit($id)
{
$orders = Order::with('address')->where('user_id', $id)->paginate(config('wfhshop.page_size'));
$order_status = config('wfhshop.order_status');
return view('admin.order.index', ['orders' => $orders, 'order_status' => $order_status]);
}
示例12: getmycom
public function getmycom($id)
{
$order = Order::with('order_goods.good', 'comments')->find($id);
return view('wechat.comment_done', ['order_goods' => $order->order_goods, 'comments' => $order->comments]);
}
示例13: getProcessingOrdersForUser
public function getProcessingOrdersForUser($userId)
{
return \App\Models\Order::with('products')->where('user_id', $userId)->where('status', 'processing')->get();
}
示例14: show
public function show($id)
{
$orders = Order::with('address')->where('status', $id)->orderBy('created_at', 'desc')->paginate(config('wfhshop.page_size'));
$order_status = config('wfhshop.order_status');
return view('admin.order.show', ['orders' => $orders, 'id' => $id, 'order_status' => $order_status]);
}