admin/models/ReviewSearch.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 = Review::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort' => [
                'defaultOrder' => [
                    'position' => SORT_DESC
                ],
            ],
        ]);
        if ($this->all) {
            $dataProvider->pagination = false;
        }
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        if (!$this->status) {
            $query->where(['!=', 'status', Review::STATUS_DELETED]);
        }
        $query->andFilterWhere([
            'id' => $this->id,
            'rating' => $this->rating,
            'created_at' => $this->created_at,
            'position' => $this->position,
            'status' => $this->status,
            'product_id' => $this->product_id,
        ]);
        $query->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'text', $this->text])
            ->andFilterWhere(['like', 'answer', $this->answer])
            ->andFilterWhere(['like', 'email', $this->email]);
        if ($this->answer == 1) {
            $query->andWhere(['answer' => null]);
        } else if ($this->answer == 2) {
            $query->andWhere(['not', ['answer' => null]]);
        }
        return $dataProvider;
    }
public function search ( $ params ) { $ query = Review :: find ( ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'defaultOrder' => [ 'position' => SORT_DESC ] , ] , ] ) ; if ( $ this -> all ) { $ dataProvider -> pagination = false ; } $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } if ( ! $ this -> status ) { $ query -> where ( [ '!=' , 'status' , Review :: STATUS_DELETED ] ) ; } $ query -> andFilterWhere ( [ 'id' => $ this -> id , 'rating' => $ this -> rating , 'created_at' => $ this -> created_at , 'position' => $ this -> position , 'status' => $ this -> status , 'product_id' => $ this -> product_id , ] ) ; $ query -> andFilterWhere ( [ 'like' , 'name' , $ this -> name ] ) -> andFilterWhere ( [ 'like' , 'text' , $ this -> text ] ) -> andFilterWhere ( [ 'like' , 'answer' , $ this -> answer ] ) -> andFilterWhere ( [ 'like' , 'email' , $ this -> email ] ) ; if ( $ this -> answer == 1 ) { $ query -> andWhere ( [ 'answer' => null ] ) ; } else if ( $ this -> answer == 2 ) { $ query -> andWhere ( [ 'not' , [ 'answer' => null ] ] ) ; } 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