| Current Path : /var/www/html/elibrary/backend/modules/contentStatistics/models/ |
| Current File : /var/www/html/elibrary/backend/modules/contentStatistics/models/ContentStatisticsSearch.php |
<?php
namespace backend\modules\contentStatistics\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\contentStatistics\models\ContentStatistics;
/**
* ContentStatisticsSearch represents the model behind the search form of `backend\modules\contentStatistics\models\ContentStatistics`.
*/
class ContentStatisticsSearch extends ContentStatistics {
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['stats_id', 'stats_main', 'stats_parent_id'], 'integer'],
[['stats_status', 'stats_type', 'stats_language', 'stats_title', 'stats_content', 'stats_item', 'created_at', 'created_by', 'updated_at', 'updated_by', 'stats_code'], 'safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios() {
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params) {
$query = ContentStatistics::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => false,]]);
$dataProvider->setSort(['defaultOrder' => ['stats_sort' => SORT_ASC]]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere(['=', 'stats_status', $this->stats_status])
->andFilterWhere(['=', 'stats_type', $this->stats_type])
->andFilterWhere(['like', 'stats_title', $this->stats_title])
->andFilterWhere(['like', 'stats_content', $this->stats_content])
->andFilterWhere(['like', 'stats_item', $this->stats_item])
->andFilterWhere(['like', 'stats_code', $this->stats_code]);
$query->andFilterWhere(['=', 'stats_main', 1]);
return $dataProvider;
}
}