| Current Path : /var/www/html/ebook/backend/models/frontendcontenthistory/ |
| Current File : /var/www/html/ebook/backend/models/frontendcontenthistory/FrontendContentHistorySearch.php |
<?php
namespace backend\models\frontendcontenthistory;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\frontendcontenthistory\FrontendContentHistory;
/**
* FrontendContentHistorySearch represents the model behind the search form of `backend\models\frontendcontenthistory\FrontendContentHistory`.
*/
class FrontendContentHistorySearch extends FrontendContentHistory
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['content_history_id', 'history_content_id', 'history_page_id', 'history_category_id', 'created_by'], 'integer'],
[['history_content_title', 'history_content', 'created_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 = FrontendContentHistory::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => [
'defaultOrder' => ['content_history_id' => SORT_DESC]
]
]);
$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([
'content_history_id' => $this->content_history_id,
'history_content_id' => $this->history_content_id,
'history_page_id' => $this->history_page_id,
'history_category_id' => $this->history_category_id,
'created_at' => $this->created_at,
'created_by' => $this->created_by,
]);
$query->andFilterWhere(['like', 'history_content_title', $this->history_content_title])
->andFilterWhere(['like', 'history_content', $this->history_content]);
return $dataProvider;
}
}