public function add($params, $template = null) { $order = \Veer\Models\Order::find(array_get($params, 'orders_id')); $status = \Veer\Models\OrderStatus::find(array_get($params, 'status_id')); $payment = $payment_method = array_get($params, 'payment_method'); $sendEmail = array_pull($params, 'sendTo', null); if (empty($payment)) { $payment = \Veer\Models\OrderPayment::find(array_get($params, 'payment_method_id')); $payment_method = isset($payment->name) ? $payment->name : $payment_method; } $content = ''; if (!empty($template)) { /* leave 'view' instead of 'viewx' because we always need (rendered) html representation of the bill */ $content = view("components.bills." . $template, ["order" => $order, "status" => $status, "payment" => $payment, "price" => array_get($params, 'price')])->render(); } $b = new \Veer\Models\OrderBill(); $b->fill($params); $b->users_id = isset($order->users_id) ? $order->users_id : 0; $b->payment_method = $payment_method; $b->content = $content; if (!empty($sendEmail)) { $b->sent = true; } $b->save(); if (!empty($sendEmail) && is_object($order)) { $this->sendEmailBillCreate($b, $order); } return $this; }
/** * show One order */ public function getOrderAdvanced($order) { if ($order == "new") { return new \stdClass(); } $items = \Veer\Models\Order::find($order); if (is_object($items)) { $this->loadOrderRelations($items); $this->loadSiteTitle($items); if (is_object($items->products)) { $items->products = $this->regroupOrderProducts($items->products); } if (is_object($items->orderContent)) { $items->orderContent = $this->orderContentParse($items->orderContent, $items->products); } } if (empty(app('veer')->loadedComponents['billsTypes'])) { $this->getExistingBillTemplates(); } return $items; }
protected function deleteOrder($id) { $order = \Veer\Models\Order::find($id); if (is_object($order)) { \Veer\Models\OrderHistory::where('orders_id', '=', $id)->delete(); $order->orderContent()->delete(); $order->bills()->delete(); $order->secrets()->delete(); // communications skip $order->delete(); return true; } return false; }
public function getOrder($id) { $this->id = $id; $this->order = \Veer\Models\Order::find($id); return $this; }