本文整理汇总了PHP中OrderDetail::where方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderDetail::where方法的具体用法?PHP OrderDetail::where怎么用?PHP OrderDetail::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderDetail
的用法示例。
在下文中一共展示了OrderDetail::where方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$days_to_wait = Config::get('store.days_to_close');
//\DB::enableQueryLog();
$this->info("Checks If there are orders to be closed ({$days_to_wait} Days Old)");
//Checks all closed orders that has not been rated nor mail has been sent and where updated 5 days ago
//and the mails has not been sent yet
$orders = Order::where('status', 'sent')->where('updated_at', '<', Carbon::now()->subDays($days_to_wait))->get();
//$this->info(print_r(\DB::getQueryLog()));
$this->info("Orders That need to be closed: " . $orders->count());
foreach ($orders as $order) {
$this->info("Order: " . $order->id . ' Needs to be closed');
$buyer = User::find($order->user_id);
if ($buyer) {
$email = $buyer->email;
$mail_subject = trans('email.cron_emails.order_closed_for_time');
$data = ['email_message' => $mail_subject, 'email' => $email, 'subject' => $mail_subject, 'order_id' => $order->id];
Mail::queue('emails.cron.close_order', $data, function ($message) use($data) {
$message->to($data['email'])->subject($data['subject']);
});
$order->status = 'closed';
$order->end_date = DB::raw('NOW()');
$seller = User::findOrFail($order->seller_id);
if ($seller) {
$order_content = OrderDetail::where('order_id', $order->id)->get();
$total_points = 0;
foreach ($order_content as $order_detail) {
$total_points += $order_detail->quantity * $order_detail->price;
$order_detail->status = 0;
$order_detail->delivery_date = DB::raw('NOW()');
$order_detail->save();
if ($order_detail->product->type != 'item') {
switch ($order_detail->product->type) {
case 'key':
$virtualProductsId = VirtualProductOrder::select('virtual_product_id')->where('order_id', $order->id)->get()->toArray();
VirtualProduct::where('product_id', $order_detail->product_id)->whereIn('id', $virtualProductsId)->update(['status' => 'closed']);
break;
}
}
}
$seller->modifyPoints($total_points, 8, $order->id);
}
$order->save();
}
}
}