当前位置: 首页>>代码示例>>PHP>>正文


PHP User::findOne方法代码示例

本文整理汇总了PHP中app\modules\user\models\User::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findOne方法的具体用法?PHP User::findOne怎么用?PHP User::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\modules\user\models\User的用法示例。


在下文中一共展示了User::findOne方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUser

 /**
  * Finds user by [[email]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findOne(['email' => $this->email]);
     }
     return $this->_user;
 }
开发者ID:bariew,项目名称:sitown,代码行数:12,代码来源:LoginForm.php

示例2: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findOne(['email' => $this->email, 'status' => User::STATUS_ACTIVE]);
     }
     return $this->_user;
 }
开发者ID:Dominus77,项目名称:blog,代码行数:12,代码来源:PasswordResetRequestForm.php

示例3: getUser

 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findOne(['id' => Yii::$app->user->id]);
     }
     return $this->_user;
 }
开发者ID:goncharovln,项目名称:keywords,代码行数:7,代码来源:PasswordChangeForm.php

示例4: actionListByAgent

 public function actionListByAgent($id)
 {
     $searchModel = new OrdersSearch();
     $dataProvider = $searchModel->searchListByAgent(Yii::$app->request->queryParams, $id);
     $user = User::findOne($id);
     return $this->render('listByAgent', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'user' => $user]);
 }
开发者ID:kvaxminsk,项目名称:belpharma2,代码行数:7,代码来源:OrdersController.php

示例5: findModel

 /**
  * @param $username
  * @return null|static
  * @throws Exception
  */
 private function findModel($username)
 {
     if (!($model = User::findOne(['username' => $username]))) {
         throw new Exception('User not found');
     }
     return $model;
 }
开发者ID:knyazushka,项目名称:z34lot.new,代码行数:12,代码来源:UsersController.php

示例6: findModel

 /**
  * 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 \app\modules\user\models\User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = User::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:obedkin,项目名称:atlant,代码行数:15,代码来源:DefaultController.php

示例7: findModel

 protected function findModel($id)
 {
     if (($model = Yii::$app->user->id == $id ? Yii::$app->user->identity : User::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:hackvijay,项目名称:yii-qa,代码行数:8,代码来源:HomeController.php

示例8: testChangeCorrect

 public function testChangeCorrect()
 {
     /** @var User $user */
     $user = User::findOne($this->users[0]['id']);
     $form = new PasswordChangeForm($user);
     $form->setAttributes(['currentPassword' => 'adminpass', 'newPassword' => 'new-password', 'newPasswordRepeat' => 'new-password']);
     expect('password is changed', $form->changePassword())->true();
     expect('password is correct', $user->validatePassword('new-password'))->true();
 }
开发者ID:oke11o,项目名称:seokeys,代码行数:9,代码来源:PasswordChangeFormTest.php

示例9: testUpdateCorrect

 public function testUpdateCorrect()
 {
     /** @var User $user */
     $user = User::findOne($this->users[0]['id']);
     $form = new ProfileUpdateForm($user);
     $form->setAttributes(['email' => 'new-email@site.com']);
     expect('user is updated', $form->update())->true();
     expect('email is new', $user->email)->equals('new-email@site.com');
 }
开发者ID:cleverid,项目名称:seokeys,代码行数:9,代码来源:ProfileUpdateFormTest.php

示例10: findModel

 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @param bool $search
  * @return User|UserSearch the loaded model
  * @throws NotFoundHttpException
  */
 protected function findModel($id, $search = false)
 {
     if ($search) {
         $model = new UserSearch();
     } elseif (!$id) {
         $model = new User();
     } elseif (!($model = User::findOne($id))) {
         throw new NotFoundHttpException(\Yii::t('modules/user', 'User not found'));
     }
     return $model;
 }
开发者ID:bariew,项目名称:sitown,代码行数:19,代码来源:UserController.php

示例11: resetPasword

 public function resetPasword()
 {
     if ($user = User::findOne(['email' => $this->email])) {
         $new_password = substr(Yii::$app->security->generateRandomString(), 0, 6);
         $user->setPassword($new_password);
         if ($user->save()) {
             return \Yii::$app->mailer->compose(['html' => '@app/modules/user/mails/passwordReset'], ['username' => $user->username, 'password' => $new_password])->setFrom([\Yii::$app->params['adminEmail'] => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send();
         }
     }
     return false;
 }
开发者ID:MaratCrash,项目名称:3dligatest,代码行数:11,代码来源:PasswordResetForm.php

示例12: sendEmail

 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         $user->generatePasswordResetToken();
         if ($user->save()) {
             return \Yii::$app->mailer->compose('recover', ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Востановление пароля на сайте ' . \Yii::$app->name)->send();
         }
     }
     return false;
 }
开发者ID:akula22,项目名称:fifa,代码行数:17,代码来源:RecoverPassword.php

示例13: sendEmail

 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::S_ACTIVE, 'email' => $this->email]);
     if ($user) {
         $user->generatePasswordResetToken();
         if ($user->save()) {
             Yii::$app->mailer->compose('@app/modules/user/mails/passwordReset', ['user' => $user])->setFrom([Yii::$app->params['adminEmail'] => Yii::$app->name])->setTo($this->email)->setSubject(Yii::t('frontend', 'Password reset for {name}', ['name' => Yii::$app->name]))->send();
         }
     }
     return false;
 }
开发者ID:oakcms,项目名称:oakcms,代码行数:17,代码来源:PasswordResetRequestForm.php

示例14: change

 public function change()
 {
     if ($this->validate()) {
         $id = Yii::$app->user->id;
         $model = User::findOne(['id' => $id]);
         if (!empty($model)) {
             $model->setPassword($this->new_password);
             return $model->save(false);
         }
     }
     return false;
 }
开发者ID:nicovicz,项目名称:portalctv,代码行数:12,代码来源:ChangePasswordForm.php

示例15: testSendEmailCorrectUser

 public function testSendEmailCorrectUser()
 {
     $model = new PasswordResetRequestForm(3600);
     $model->email = $this->users[0]['email'];
     /** @var User $user */
     $user = User::findOne(['password_reset_token' => $this->users[0]['password_reset_token']]);
     expect('email sent', $model->sendEmail())->true();
     expect('user has valid token', $user->password_reset_token)->notNull();
     expect('message file exists', file_exists($this->getMessageFile()))->true();
     $message = file_get_contents($this->getMessageFile());
     expect('message file "from" is correct', $message)->contains(Yii::$app->params['supportEmail']);
     expect('message file "to" is correct', $message)->contains($model->email);
 }
开发者ID:elisdn,项目名称:seokeys,代码行数:13,代码来源:PasswordResetRequestFormTest.php


注:本文中的app\modules\user\models\User::findOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。