models/FilesSearch.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 = Files::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->innerJoinWith([
            'user' => function (\yii\db\ActiveQuery $query) {
                $query->andFilterWhere([User::tableName() . '.id' => \Yii::$app->user->id]);
            }
        ]);
        $query->andFilterWhere([
            'id' => $this->id,
            'user_id' => $this->user_id,
            'size' => $this->size,
            'uploaded_at' => $this->uploaded_at,
            'downloaded' => $this->downloaded,
        ]);
        $query->andFilterWhere(['like', 'title', $this->title])
            ->andFilterWhere(['like', 'description', $this->description])
            ->andFilterWhere(['like', 'extention', $this->extention]);
        return $dataProvider;
    }
public function search ( $ params ) { $ query = Files :: find ( ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , ] ) ; $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ query -> innerJoinWith ( [ 'user' => function ( \ yii \ db \ ActiveQuery $ query ) { $ query -> andFilterWhere ( [ User :: tableName ( ) . '.id' => \ Yii :: $ app -> user -> id ] ) ; } ] ) ; $ query -> andFilterWhere ( [ 'id' => $ this -> id , 'user_id' => $ this -> user_id , 'size' => $ this -> size , 'uploaded_at' => $ this -> uploaded_at , 'downloaded' => $ this -> downloaded , ] ) ; $ query -> andFilterWhere ( [ 'like' , 'title' , $ this -> title ] ) -> andFilterWhere ( [ 'like' , 'description' , $ this -> description ] ) -> andFilterWhere ( [ 'like' , 'extention' , $ this -> extention ] ) ; 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