backend/models/search/ServersSearch.php
/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
Creates data provider instance with search query applied
@param array $params


Creates data provider instance with search query applied @param array $params
public function search($params)
    {
        $query = Servers::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort'=> [
                'defaultOrder' => ['server_type'=>SORT_DESC],
                'attributes' => [
                    'server_id',
                    'server_type',
                    'server_status',
                ]
            ],
            'pagination' => [
                'pageSize' => 100,
                'route'=>'servers/index',
            ],
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->andFilterWhere([
            'server_id' => $this->server_id,
            'server_port' => $this->server_port,
            'server_status' => $this->server_status,
        ]);
        $query->andFilterWhere(['like', 'server_type', $this->server_type])
            ->andFilterWhere(['like', 'server_title', $this->server_title])
            ->andFilterWhere(['like', 'server_url', $this->server_url])
            ->andFilterWhere(['like', 'server_ip', $this->server_ip]);
        return $dataProvider;
    }
public function search ( $ params ) { $ query = Servers :: find ( ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'defaultOrder' => [ 'server_type' => SORT_DESC ] , 'attributes' => [ 'server_id' , 'server_type' , 'server_status' , ] ] , 'pagination' => [ 'pageSize' => 100 , 'route' => 'servers/index' , ] , ] ) ; $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'server_id' => $ this -> server_id , 'server_port' => $ this -> server_port , 'server_status' => $ this -> server_status , ] ) ; $ query -> andFilterWhere ( [ 'like' , 'server_type' , $ this -> server_type ] ) -> andFilterWhere ( [ 'like' , 'server_title' , $ this -> server_title ] ) -> andFilterWhere ( [ 'like' , 'server_url' , $ this -> server_url ] ) -> andFilterWhere ( [ 'like' , 'server_ip' , $ this -> server_ip ] ) ; return $ dataProvider ; }
Creates data provider instance with search query applied
 @param array $params
Creates data provider instance with search query applied @param array $params
// add conditions that should always apply here // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); // grid filtering conditions