models/CarSearch.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 = Car::find()
                 ->joinWith('model.brand')
                 ->joinWith('engine')
                 ->joinWith('wheelDrive');
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort' => false,
            'pagination' => [
              'pageSize' => 5,
              'forcePageParam' => false,
              'pageSizeParam' => false
            ],
        ]);
        $this->load($params,'');
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->andFilterWhere([
            'brand' => $this->brand,
            'model' => $this->model,
            'engine' => $this->engine,
            'wheel_drive' => $this->wheelDrive
        ]);
        return $dataProvider;
    }
public function search ( $ params ) { $ query = Car :: find ( ) -> joinWith ( 'model.brand' ) -> joinWith ( 'engine' ) -> joinWith ( 'wheelDrive' ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => false , 'pagination' => [ 'pageSize' => 5 , 'forcePageParam' => false , 'pageSizeParam' => false ] , ] ) ; $ this -> load ( $ params , '' ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'brand' => $ this -> brand , 'model' => $ this -> model , 'engine' => $ this -> engine , 'wheel_drive' => $ this -> wheelDrive ] ) ; return $ dataProvider ; }
Creates data provider instance with search query applied
 @param array $params
Creates data provider instance with search query applied @param array $params
// uncomment the following line if you do not want to any records when validation fails // $query->where('0=1');