params = $params; } public function apply( $model, RepositoryInterface $repository ) { if (!empty($this->params['id'])) { $model = $model->where('id', $this->params['id']); } if (!empty($this->params['status'])) { $model = $model->where('status', $this->params['status']); } if (isset($this->params['level']) && $this->params['level'] != '') { $model = $model->where('level', $this->params['level']); } if (!empty($this->params['is_bot']) && $this->params['is_bot'] != '') { $model = $model->where('is_bot', $this->params['is_bot']); } if (!empty($this->params['user_nick'])) { $model = $model->whereHas('user', function($q) { $q->where('nick', $this->params['user_nick']); }); } if (!empty($this->params['user_code'])) { $model = $model->whereHas('user', function($q) { $q->where('code', $this->params['user_code']); }); } if (!empty($this->params['user_mobile'])) { $model = $model->whereHas('user', function($q) { $q->where('mobile', $this->params['user_mobile']); }); } return $model; } }