| Current Path : /var/www/html/dosm/backend/modules/statisticsFun/models/ |
| Current File : /var/www/html/dosm/backend/modules/statisticsFun/models/StatsFunChildSearch.php |
<?php
namespace backend\modules\statisticsFun\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\statisticsFun\models\StatsFunChild;
/**
* StatsFunChildSearch represents the model behind the search form of `backend\modules\statisticsFun\models\StatsFunChild`.
*/
class StatsFunChildSearch extends StatsFunChild {
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['child_id', 'main_id', 'child_order'], 'integer'],
[['child_title', 'child_source', 'child_type', 'child_thumbnail', 'child_background', 'created_at', 'created_by', 'updated_at', 'updated_by'], '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 = StatsFunChild::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10,]]);
$dataProvider->setSort(['defaultOrder' => ['child_order' => 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([
'child_id' => $this->child_id,
'main_id' => $this->main_id,
'child_order' => $this->child_order,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'child_title', $this->child_title])
->andFilterWhere(['like', 'child_source', $this->child_source])
->andFilterWhere(['like', 'child_type', $this->child_type])
->andFilterWhere(['like', 'child_thumbnail', $this->child_thumbnail])
->andFilterWhere(['like', 'child_background', $this->child_background])
->andFilterWhere(['like', 'created_by', $this->created_by])
->andFilterWhere(['like', 'updated_by', $this->updated_by]);
return $dataProvider;
}
}