public function getUser() { if ($this->_user === false) { $this->_user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]); } return $this->_user; }
protected function findFreeUsername($username, $n = '') { $exists = User::findOne(['username' => $username . $n]); if ($exists) { $n = $n == '' ? 2 : $n + 1; return $this->findFreeUsername($username, $n); } return $username . $n; }
/** * @param int $id User ID * * @throws \yii\web\NotFoundHttpException * @return string */ public function actionSet($id) { $user = User::findOne($id); if (!$user) { throw new NotFoundHttpException('User not found'); } $permissionsByGroup = []; $permissions = Permission::find()->andWhere([Yii::$app->getModule('user')->auth_item_table . '.name' => array_keys(Permission::getUserPermissions($user->id))])->joinWith('group')->all(); foreach ($permissions as $permission) { $permissionsByGroup[@$permission->group->name][] = $permission; } return $this->renderIsAjax('set', compact('user', 'permissionsByGroup')); }
public function getUser() { return User::findOne(['email' => $this->email]); }
/** * Finds the User model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return User the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if ($this->_model === false) { $this->_model = User::findOne($id); } if ($this->_model !== null) { return $this->_model; } throw new NotFoundHttpException('The requested page does not exist.'); }