| Current Path : /var/www/html/ukas/backend/modules/customDashboard/models/ |
| Current File : /var/www/html/ukas/backend/modules/customDashboard/models/DataDashboardSearch.php |
<?php
namespace backend\modules\customDashboard\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\customDashboard\models\DataDashboard;
/**
* DataDashboardSearch represents the model behind the search form of `backend\models\data\DataDashboard`.
*/
class DataDashboardSearch extends DataDashboard {
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['id', 'sorting', 'activation_status', 'created_by', 'updated_by'], 'integer'],
[['title', 'content', 'created_at', 'updated_at'], '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 = DataDashboard::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => false,]]);
$dataProvider->setSort(['defaultOrder' => ['sorting' => 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(['like', 'title', $this->title])
->andFilterWhere(['like', 'content', $this->content]);
$query->andFilterWhere(['=', 'activation_status', $this->activation_status]);
$query->andFilterWhere(['=', 'sorting', $this->sorting]);
return $dataProvider;
}
}