protected function prepareData($fill) { if (empty($fill['sites_id'])) { $fill['sites_id'] = app('veer')->siteId; } if (empty($fill['users_id']) && $this->action != 'add') { $fill['users_id'] = \Auth::id(); } foreach (['free', 'close', 'hidden', 'archive', 'delivery_free', 'delivery_hold', 'payment_hold', 'payment_done'] as $key) { $fill[$key] = isset($fill[$key]) ? 1 : 0; } if ($fill['close']) { $fill['close_time'] = now(); } $fill['progress'] = isset($fill['progress']) ? strtr($fill['progress'], ["%" => ""]) : 5; $fill['delivery_plan'] = !empty($fill['delivery_plan']) ? parse_form_date($fill['delivery_plan']) : null; $fill['delivery_real'] = !empty($fill['delivery_real']) ? parse_form_date($fill['delivery_real']) : null; $fill += ['cluster_oid' => null, 'cluster' => null, 'delivery_method_id' => $this->order->delivery_method_id, 'payment_method_id' => $this->order->payment_method_id, 'status_id' => $this->order->status_id, 'userbook_id' => $this->order->userbook_id]; if ($this->order->cluster_oid != $fill['cluster_oid'] || $this->order->cluster != $fill['cluster']) { $existingOrders = \Veer\Models\Order::where('sites_id', '=', $fill['sites_id'])->where('cluster', '=', $fill['cluster'])->where('cluster_oid', '=', $fill['cluster_oid'])->first(); // we cannot update cluster ids if they already exist if (is_object($existingOrders) || empty($fill['cluster_oid'])) { array_forget($fill, ['cluster_oid', 'cluster']); } } if ($this->order->delivery_method_id != $fill['delivery_method_id'] && empty($fill['delivery_method'])) { $fill['delivery_method'] = \Veer\Models\OrderShipping::where('id', '=', $fill['delivery_method_id'])->pluck('name'); } if ($this->order->payment_method_id != $fill['payment_method_id'] && empty($fill['payment_method'])) { $fill['payment_method'] = \Veer\Models\OrderPayment::where('id', '=', $fill['payment_method_id'])->pluck('name'); } return $fill; }
/** * Get all veer shop shipping * @return object */ function shipping($siteId = null) { if (empty($siteId)) { $shipping = \Veer\Models\OrderShipping::select(); } else { $shipping = \Veer\Models\OrderShipping::where('sites_id', '=', $siteId); } return \Cache::remember('listofShippingMethods-' . $siteId, 0.5, function () use($shipping) { return $shipping->where('enable', '=', true)->orderBy('manual_order', 'asc')->get(); }); }