本文整理汇总了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();
}
示例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'));
}
示例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);
});
}
}
示例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;
}
示例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));
}
}
}
示例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');
}
}
示例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));
}
}
}
示例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));
}
}
}
示例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');
}
示例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]);
}
示例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'));
}
示例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'));
}
示例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');
}
示例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();
}
});
}
示例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');
}