'json' ]; protected $appends = [ 'info' ]; public function scopeSearch($query,$search) { $query->uniacid(); if ($search['member_id']) { $query->where('member_id', $search['member_id']); } if ($search['order_sn']) { $query->where('content', $search['order_sn']); } if ($search['is_time']) { $time = [strtotime($search['start_time']),strtotime($search['end_time'])]; $query->whereBetween('created_at', $time); } if ($search['member']) { $query->whereHas('hasOneMember',function ($q)use ($search) { $q->searchLike($search['member_id']); }); } return $query; // TODO: Change the autogenerated stub } public static function addRow($row) { $model = new self(); $model->fill($row); $model->save(); return $model; } public static function updateRow($row) { $model = self::where('order_id', $row['order_id'])->where('code',$row['code']); $model->update($row); return $model; } public static function updateStatus($order_id) { $model = self::where('order_id', $order_id)->update(['status' => 1]); return $model; } public static function getInfoByOrderId($order_id) { return self::select()->where('order_id', $order_id); } public function getInfoAttribute() { $info = DB::table($this->table_name)->select() ->whereIn('id', $this->ids) ->get(); return $info; } public function hasOneOrderGoods() { return $this->hasOne(OrderGoods::class,'order_id','order_id'); } public function hasOneCashierOrder() { return $this->hasOne(CashierOrder::class,'order_id','order_id'); } public function hasOneStoreOrder() { return $this->hasOne(StoreOrder::class,'order_id','order_id'); } public function hasOneSupplierOrder() { return $this->hasOne(SupplierOrder::class,'order_id','order_id'); } public function hasOneMember() { return $this->hasOne(Member::class,'uid','member_id'); } }