params = $params; } /** * @param Builder $model * @param RepositoryInterface $repository * @return mixed|void */ public function apply( $model, RepositoryInterface $repository ) { if (!empty($this->params['manager_uid'])) { $model = $model->where('manager_uid', $this->params['manager_uid']); } if (!empty($this->params['username'])) { $model = $model->where('username', 'LIKE', '%'. $this->params['username'] .'%'); } if (!empty($this->params['nick'])) { $model = $model->where('nick', 'LIKE', '%'. $this->params['nick'] .'%'); } if (isset($this->params['is_locked'])) { $is_locked = intval($this->params['is_locked']); if ($is_locked == 1) { $model = $model->whereNotNull('locked_at'); } elseif ($is_locked == -1) { $model = $model->whereNull('locked_at'); } } if (!empty($this->params['role_id'])) { $model = $model->where('role_id', $this->params['role_id']); } if (!empty($this->params['email'])) { $model = $model->where('email', $this->params['email']); } return $model; } }