| Current Path : /var/www/html/akept/backend/models/frontendmenu/ |
| Current File : /var/www/html/akept/backend/models/frontendmenu/FrontendMenuSearch.php |
<?php
namespace backend\models\frontendmenu;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\frontendmenu\FrontendMenu;
/**
* FrontendMenuSearch represents the model behind the search form about `backend\models\frontendmenu\FrontendMenu`.
*/
class FrontendMenuSearch extends FrontendMenu
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['menu_id', 'menu_order', 'page_id', 'menu_parent_id','site_id'], 'integer'],
[['menu_name', 'menu_link', 'menu_type'], '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 = FrontendMenu::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$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([
'site_id' => $this->site_id,
'menu_id' => $this->menu_id,
'menu_order' => $this->menu_order,
'menu_parent_id' => $this->menu_parent_id,
]);
$query->andFilterWhere(['like', 'menu_name', $this->menu_name])
->andFilterWhere(['like', 'menu_link', $this->menu_link])
->andFilterWhere(['like', 'menu_type', $this->menu_type]);
return $dataProvider;
}
}