/** * Returns the order that has status = Shipped * @param $query * @return mixed */ public static function whereShipped($query) { return $query->where(function ($q) { $q->where('order_status_id', '=', OrderStatus::Shipped()->id); }); }
public function shipOrder(Order $order, $trackingId) { $order->tracking_id = $trackingId; $order->order_status_id = OrderStatus::Shipped()->id; $order->shipped_at = Carbon::now(); $order->shipped_by_id = Auth::user()->id; $order->save(); User::createUserEvent($order->user, ['controller' => 'timeline', 'route' => '/order-shipped', 'target_id' => $order->id, 'parameter_id' => Auth::user()->id]); if ($order->customer) { NotificationRequest::create(['target_id' => $order->id, 'route' => 'order-shipped', 'channel' => 'Sms', 'to_user_id' => $order->user->id, 'to_customer_id' => $order->customer_id]); } else { NotificationRequest::create(['target_id' => $order->id, 'route' => 'order-shipped', 'channel' => 'Sms', 'to_user_id' => $order->user->id]); } }