| Current Path : /var/www/html/dosm/backend/models/ |
| Current File : /var/www/html/dosm/backend/models/JournalChapterSearch.php |
<?php
namespace backend\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\JournalChapter;
/**
* PublicationChapterSearch represents the model behind the search form of `backend\modules\publicationDocument\models\PublicationChapter`.
*/
class JournalChapterSearch extends JournalChapter {
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['chapter_id', 'version_id'], 'integer'],
[['chapter_title', 'chapter_ebook1', 'chapter_ebook2', 'chapter_ebook3', 'total_size', 'total_pages', '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 = JournalChapter::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(['like', 'chapter_title', $this->chapter_title])
->andFilterWhere(['like', 'chapter_ebook1', $this->chapter_ebook1])
->andFilterWhere(['like', 'chapter_ebook2', $this->chapter_ebook2])
->andFilterWhere(['like', 'chapter_ebook3', $this->chapter_ebook3])
->andFilterWhere(['like', 'total_size', $this->total_size])
->andFilterWhere(['like', 'total_pages', $this->total_pages]);
$query->andWhere(['=', 'version_id', $this->version_id]);
return $dataProvider;
}
}