| Current Path : /var/www/html/learn/backend/modules/learning/models/ |
| Current File : /var/www/html/learn/backend/modules/learning/models/LearningChapterSearch.php |
<?php
namespace backend\modules\learning\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\learning\models\LearningChapter;
/**
* LearningChapterSearch represents the model behind the search form of `backend\modules\learning\models\LearningChapter`.
*/
class LearningChapterSearch extends LearningChapter {
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['chapter_id', 'main_id', 'chapter_sort'], 'integer'],
[['chapter_title', 'chapter_type', 'chapter_content', 'chapter_status', 'created_at', 'created_by', 'created_user_type', 'updated_at',
'updated_by', 'updated_user_type','chapter_time'], '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 = LearningChapter::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => false,]]);
$dataProvider->setSort(['defaultOrder' => ['chapter_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(['main_id' => $this->main_id]);
$query->andFilterWhere(['like', 'chapter_title', $this->chapter_title])
->andFilterWhere(['like', 'chapter_type', $this->chapter_type])
->andFilterWhere(['like', 'chapter_content', $this->chapter_content])
->andFilterWhere(['like', 'chapter_status', $this->chapter_status])
->andFilterWhere(['=', 'chapter_time', $this->chapter_time])
->andFilterWhere(['=', 'chapter_sort', $this->chapter_sort]);
return $dataProvider;
}
}