hasMany(OrderProductModel::class, 'order_id','id')->where('is_delete',0); } public function payments() { return $this->hasMany(OrderPaymentModel::class, 'order_id','id')->where('is_delete',0); } public function annuals() { return $this->hasMany(OrderAnnualFeeModel::class, 'order_id','id')->where('is_delete',0); } public function proceeds() { return $this->hasMany(OrderProceedsModel::class, 'order_id','id')->where('is_delete',0); } public function store() { return $this->hasOne(StoreModel::class, 'id', 'store_id'); } public function findByPaginate(array $params) { $where = [ ['is_delete', '=', 0] ]; if($params['store_id'] > 0) array_push($where,['store_id', '=', $params['store_id']]); if($params['type'] > 0) array_push($where,['type', '=', $params['type']]); return $this->where($where) ->with(['products','store']) ->order('create_time','desc') ->paginate(['list_rows'=>10, "query" => $params]); } public function findById($id) { return $this->where('is_delete',0) ->with([ 'products', 'payments', 'payments.payment_channel', // 'payments.card_config', 'annuals', 'proceeds' ])->find($id); } }