Exemple #1
0
 public function update($id, $data)
 {
     $o = \Veer\Models\OrderStatus::find($id);
     if (is_object($o)) {
         $data += $o->toArray();
         $this->addOrUpdateGlobalStatus($o, ['name' => $data['name'], 'manual_order' => $data['manual_order'], 'color' => $data['color'], 'flag' => $data['flag']]);
     }
     return $this;
 }
Exemple #2
0
 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;
 }