'php:Y-m-d'], ]; } /** * @param array $params * @return ActiveDataProvider */ public function search(array $params): ActiveDataProvider { $query = User::find()->alias('u'); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); if (!$this->validate()) { $query->where('0=1'); return $dataProvider; } $query->andFilterWhere([ 'u.id' => $this->id, 'u.status' => $this->status, ]); if (!empty($this->role)) { $query->innerJoin('{{%auth_assignments}} a', 'a.user_id = u.id'); $query->andWhere(['a.item_name' => $this->role]); } $query ->andFilterWhere(['like', 'u.username', $this->username]) ->andFilterWhere(['like', 'u.email', $this->email]) ->andFilterWhere(['>=', 'u.created_at', $this->date_from ? strtotime($this->date_from . ' 00:00:00') : null]) ->andFilterWhere(['<=', 'u.created_at', $this->date_to ? strtotime($this->date_to . ' 23:59:59') : null]); return $dataProvider; } public function rolesList(): array { return ArrayHelper::map(\Yii::$app->authManager->getRoles(), 'name', 'description'); } }