params = $params; } /** * @param Model $model * @param Repository $repository * @return mixed */ public function apply($model, Repository $repository) { if (!empty($this->params['user_uid'])) { $model = $model->where('user_uid', $this->params['user_uid']); } if (!empty($this->params['pay_type'])) { $model = $model->where('pay_type', $this->params['pay_type']); } if (!empty($this->params['order_status'])) { $model = $model->where('order_status', (int)$this->params['order_status']); } if (!empty($this->params['mom_app_uid'])) { $model = $model->where('mom_app_uid', $this->params['mom_app_uid']); } if (!empty($this->params['start_date']) && !empty($this->params['end_date'])) { $model = $model->whereBetween('created_at', [Carbon::parse($this->params['start_date']), Carbon::parse($this->params['end_date'])]); } if (!empty($this->params['user_name'])) { $model = $model->where('user_name', 'LIKE', '%'. $this->params['user_name'] .'%'); } if (!empty($this->params['order_sn'])) { $model = $model->where('order_sn', $this->params['order_sn']); } return $model; } }