code: private function prepareQuery($targetClass, $conditions)
      {
          $query = $targetClass::find();
          $query->andWhere($conditions);
          if ($this->filter instanceof \Closure) {
              call_user_func($this->filter, $query);
          } elseif ($this->filter !== null) {
              $query->andWhere($this->filter);
          }
  
          return $query;
      }
docs: Prepares a query by applying filtering conditions defined in $conditions method property
  and [[filter]] class property.
  
  @param ActiveRecordInterface $targetClass the name of the ActiveRecord class that should be used to validate
  the uniqueness of the current attribute value.
  @param array $conditions conditions, compatible with [[\yii\db\Query::where()|Query::where()]] key-value format
  
  @return ActiveQueryInterface|ActiveQuery