/**
  * Фильтрация по атрибутам
  */
 protected function filterAttributes()
 {
     if ($this->_mainQuery) {
         if ($this->hasAttribute('id')) {
             $this->_mainQuery->andFilterWhere(['id' => $this->id]);
         }
         if ($this->hasAttribute('user_id')) {
             $this->_mainQuery->andFilterWhere(['user_id' => $this->user_id]);
         }
         if ($this->hasAttribute('type_key')) {
             $this->_mainQuery->andFilterWhere(['type_key' => $this->type_key]);
         }
         if ($this->hasAttribute('app_id')) {
             $this->_mainQuery->andFilterWhere(['app_id' => $this->app_id]);
         }
         if ($this->hasAttribute('model_name')) {
             $this->_mainQuery->andFilterWhere(['like', 'model_name', $this->model_name]);
         }
         if ($this->hasAttribute('model_name')) {
             $this->_mainQuery->andFilterWhere(['like', 'table_name', $this->table_name]);
         }
         if ($this->hasAttribute('created_at')) {
             $this->_mainQuery->andFilterWhere(['like', 'created_at', $this->created_at]);
         }
     }
 }
 /**
  * For filtering attributes
  */
 protected function filterAttributes()
 {
     if ($this->_mainQuery) {
         if ($this->hasAttribute('id')) {
             $this->_mainQuery->andFilterWhere(['id' => $this->id]);
         }
         if ($this->hasAttribute('created_at')) {
             $this->_mainQuery->andFilterWhere(['like', 'created_at', $this->created_at]);
         }
         if ($this->hasAttribute('updated_at')) {
             $this->_mainQuery->andFilterWhere(['like', 'updated_at', $this->updated_at]);
         }
     }
 }
Beispiel #3
0
 /**
  * @param ActiveQuery $query
  */
 protected function filtersForExtraColumns($query)
 {
     foreach (self::extraColumns() as $attribute) {
         $query->andFilterWhere(['like', self::columnName($attribute, false), $this->getAttribute($attribute)]);
     }
 }
Beispiel #4
0
 /**
  * Поиск по диапазону дат создания
  * @param \yii\db\ActiveQuery $q
  * @param \common\db\fields\Field $f
  */
 public function createdAtQueryModifier($q, $f)
 {
     $table = $f->model->tableName();
     $attr = $f->attr;
     $toDate = $f->model->createdAtTo ? $f->model->createdAtTo . " 23:59:59" : $f->model->createdAtTo;
     $q->andFilterWhere([">=", "{{%{$table}}}.{{%{$attr}}}", $f->model->createdAtFrom]);
     $q->andFilterWhere(["<=", "{{%{$table}}}.{{%{$attr}}}", $toDate]);
 }
 /**
  * @param $userId
  * @param ActiveQuery $query
  */
 protected function filterUserId($userId, $query)
 {
     if (strlen($this->user_id)) {
         if (!is_numeric($userId) && ($callback = Audit::getInstance()->userFilterCallback)) {
             $userId = call_user_func($callback, $userId);
         } else {
             $userId = intval($this->user_id) ?: 0;
         }
     }
     $query->andFilterWhere(['user_id' => $userId]);
 }
Beispiel #6
0
 public function equal($attribute)
 {
     $this->query->andFilterWhere([$attribute => $this->model->{$attribute}]);
 }
Beispiel #7
0
 /**
  * @param ActiveQuery $query
  */
 protected function prepareFilters($query)
 {
     $query->andFilterWhere(['id' => $this->id, 'is_super_admin' => $this->is_super_admin, 'is_active' => $this->is_active]);
     $query->andFilterWhere(['like', 'login', $this->login])->andFilterWhere(['like', 'passhash', $this->passhash])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email]);
 }