user->can('admin')) { $query = Lots::find()->orderBy('id DESC'); } else { $query = Lots::find()->where(['user_id' => Yii::$app->user->identity->id])->orderBy('date DESC'); } $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $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; } $query->andFilterWhere([ 'id' => $this->id, 'aukname' => $this->aukname, 'start_price' => $this->start_price, 'step' => $this->step, 'docs_id' => $this->docs_id, 'delivery_time' => $this->delivery_time, 'category_id' => $this->category_id, 'requisites_id' => $this->requisites_id, 'dogovor_id' => $this->dogovor_id, 'date' => $this->date, 'auction_date' => $this->auction_date, 'status' => $this->status, ]); $query->andFilterWhere(['like', 'aukname', $this->aukname]) ->andFilterWhere(['like', 'name', $this->name]) ->andFilterWhere(['like', 'description', $this->description]) ->andFilterWhere(['like', 'address', $this->address]) ->andFilterWhere(['like', 'delivery_term', $this->delivery_term]) ->andFilterWhere(['like', 'requires', $this->requires]) ->andFilterWhere(['like', 'payment_term', $this->payment_term]) ->andFilterWhere(['like', 'payment_order', $this->payment_order]) ->andFilterWhere(['like', 'member_require', $this->member_require]) ->andFilterWhere(['like', 'member_docs', $this->member_docs]) ->andFilterWhere(['like', 'notes', $this->notes]) ->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; } }