Your IP : 216.73.216.79


Current Path : /var/www/html/csm/common/models/
Upload File :
Current File : /var/www/html/csm/common/models/MenuSearch.php

<?php

namespace common\models;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\Menu;

/**
 * MenuSearch represents the model behind the search form about `app\models\Menu`.
 */
class MenuSearch extends Menu
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'menu_parent_id', 'sort', 'module_ind'], 'integer'],
            [['menu_txt', 'menu_loc', 'default_menu', 'icon_name', 'balloon_title', 'remarks', 'hide_ind', 'pic'], '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 = Menu::find();

        // 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,
        ]);

        $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;
    }
}