/** * Search users by request criteria. * * @param array|null Filter params * @return ActiveDataProvider Data provider with users */ public function search($params) { $query = User::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $this->module->recordsPerPage]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $this->addCondition($query, 'username', true); $this->addCondition($query, 'email', true); $this->addCondition($query, 'status_id'); $this->addCondition($query, 'role'); $this->addWithCondition($query, 'name', 'profile', 'name'); $this->addWithCondition($query, 'surname', 'profile', 'surname'); return $dataProvider; }
/** * Find model by ID * * @param integer|array $id User ID * * @return \vova07\users\models\backend\User User * @throws HttpException 404 error if user was not found */ protected function findModel($id) { if (is_array($id)) { /** @var User $user */ $model = User::findIdentities($id); } else { /** @var User $user */ $model = User::findIdentity($id); } if ($model !== null) { return $model; } else { throw new HttpException(404); } }