| Current Path : /var/www/html/ekursus/backend/models/ |
| Current File : /var/www/html/ekursus/backend/models/MainMenuSearch.php |
<?php
namespace backend\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
/**
* MenuSearch represents the model behind the search form about `app\models\Menu`.
*/
class MainMenuSearch extends MainMenu
{
public $id;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'sort'], 'integer'],
[['cat', 'code', 'descr', 'param1'], '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 = MainMenu::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort'=> ['defaultOrder' => ['sort' => SORT_ASC]],
'pagination' => [ 'pageSize' => 200 ],
]);
$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([
'id' => $this->id,
'sort' => $this->sort,
]);
$query
// ->andFilterWhere(['=', 'cat', $mRef->code])
->andFilterWhere(['like', 'code', $this->code])
->andFilterWhere(['like', 'descr', $this->descr])
->andFilterWhere(['like', 'param1', $this->param1]);
return $dataProvider;
}
public function searchFrontEnd($params)
{
$query = Menu::find()->where(['menucat'=>'11']);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort'=> ['defaultOrder' => ['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([
'id' => $this->id,
'menu_parent_id' => $this->menu_parent_id,
'sort' => $this->sort,
'module_ind' => $this->module_ind,
'modulecd' => $this->modulecd,
]);
$query->andFilterWhere(['like', 'menu_txt', $this->menu_txt])
->andFilterWhere(['like', 'menu_loc', $this->menu_loc])
->andFilterWhere(['like', 'default_menu', $this->default_menu])
->andFilterWhere(['like', 'icon_name', $this->icon_name])
->andFilterWhere(['like', 'balloon_title', $this->balloon_title])
->andFilterWhere(['like', 'remarks', $this->remarks])
->andFilterWhere(['like', 'hide_ind', $this->hide_ind])
->andFilterWhere(['like', 'pic', $this->pic]);
return $dataProvider;
}
}