| Current Path : /var/www/html/akept/backend/models/frontendcontent/ |
| Current File : /var/www/html/akept/backend/models/frontendcontent/FrontendContentSearch.php |
<?php
namespace backend\models\frontendcontent;
use yii\base\Model;
use yii\data\ActiveDataProvider;
/**
* FrontendContentSearch represents the model behind the search form about `backend\models\frontendcontent\FrontendContent`.
*/
class FrontendContentSearch extends FrontendContent {
/**
* @inheritdoc
*/
public function rules() {
return [
[['category_id', 'theme_id', 'page_id', 'content_order', 'content_is_php'], 'integer'],
[['content_id', 'content_details', 'content_name'], '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 = FrontendContent::find()->joinWith('theme');
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10,]]);
$dataProvider->setSort(['defaultOrder' => ['content_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([
'category_id' => $this->category_id,
'content_is_php' => $this->content_is_php,
'frontend_content.theme_id' => $this->theme_id,
]);
$query->andFilterWhere(['like', 'content_name', $this->content_name]);
return $dataProvider;
}
}