• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP models\User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: signup

 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     $auth = Yii::$app->authManager;
     $role = $auth->getRole($this->jabatan);
     if ($this->validate() && !empty($role)) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->validate() && $user->save()) {
             $person = new Person();
             $person->first_name = $this->first_name;
             $person->last_name = $this->last_name;
             $person->gender = $this->gender;
             $person->birth_date = $this->birth_date;
             $person->user_id = $user->id;
             if ($person->validate() && $person->save()) {
                 $auth->assign($role, $user->id);
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:nicovicz,项目名称:portalctv,代码行数:30,代码来源:SignupForm.php


示例2: create

 /**
  * @param Configuration $config
  * @throws \yii\base\Exception
  * @throws \yii\base\InvalidConfigException
  */
 public static function create($config)
 {
     $language = substr(Yii::$app->language, 0, 2);
     $db = Yii::$app->getDb();
     // Settings
     $db->createCommand()->batchInsert('{{%settings}}', ['group', 'name', 'value'], [['stock', 'outofstock', 0], ['stock', 'lowstock', 10], ['general', 'shopEmail', $config->shopEmail], ['general', 'adminEmail', $config->adminEmail]])->execute();
     // Currencies
     $db->createCommand()->batchInsert('{{%currency}}', ['code', 'name', 'is_default', 'rate', 'symbol'], [['EUR', 'Euro', 0, 0.0145, '€'], ['UAH', 'Hryvnia', 0, 0.3601, '₴'], ['RUB', 'Ruble', 1, 1, '₽'], ['USD', 'US Dollar', 0, 0.0158, '$']])->execute();
     // Countries
     static::callLocalized('countries', $language);
     // Users
     $root_auth_key = Yii::$app->security->generateRandomString();
     $root_password = Yii::$app->security->generatePasswordHash($config->adminPassword);
     $user = new User(['email' => $config->adminEmail, 'name' => 'admin', 'country_id' => 'us', 'address' => '7805 Southcrest Parkway, Southaven, MS(Mississippi) 38671', 'phone' => '(662) 349-7500', 'password_hash' => $root_password, 'auth_key' => $root_auth_key, 'role' => User::USER_ROLE_ADMIN]);
     $user->save();
     // Categories
     static::callLocalized('categories', $language);
     // Products
     static::callLocalized('products', $language);
     // Comments
     static::callLocalized('comments', $language);
     // Pages
     static::callLocalized('pages', $language);
     // News
     static::callLocalized('news', $language);
     // Relations
     $db->createCommand()->batchInsert('{{%relation}}', ['item_id', 'related_id', 'model'], [[1, 2, 'Product'], [1, 3, 'Product'], [3, 1, 'Product'], [3, 2, 'Product']])->execute();
 }
开发者ID:vetoni,项目名称:toko,代码行数:33,代码来源:DemoData.php


示例3: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:obedkin,项目名称:atlant,代码行数:14,代码来源:DefaultController.php


示例4: testSave

 public function testSave()
 {
     $model = new User(['username' => 'test_user', 'email' => '[email protected]', 'status' => 1]);
     $model->setPassword('new-password');
     expect('model is saved', $model->save())->true();
     expect('password is correct', $model->validatePassword('new-password'))->true();
     expect('auth key is correct', $model->auth_key)->notEmpty();
     expect('created_at is correct', $model->created_at)->notEmpty();
     expect('updated_at is correct', $model->updated_at)->notEmpty();
 }
开发者ID:oke11o,项目名称:seokeys,代码行数:10,代码来源:UserTest.php


示例5: signup

 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             return $user;
         }
     }
     return null;
 }
开发者ID:alexshadie,项目名称:wallet,代码行数:19,代码来源:SignupForm.php


示例6: signup

 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->status = User::STATUS_WAIT;
         $user->generateAuthKey();
         $user->generateEmailConfirmToken();
         if ($user->save()) {
             $auth = Yii::$app->authManager;
             $userRoleDefault = $auth->getRole('user');
             $auth->assign($userRoleDefault, $user->getId());
             $userProfile = new Profile();
             $userProfile->user_id = $user->getId();
             $userProfile->user_agent = Yii::$app->request->getUserAgent();
             $userProfile->user_ip = Yii::$app->request->getUserIP();
             $userProfile->name = $user->username;
             $userProfile->avatar_id = 1;
             //default.png (id = 1)
             $userProfile->save(false);
             Yii::$app->mailer->compose(['text' => '@app/modules/user/mails/emailConfirm'], ['user' => $user])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])->setTo($this->email)->setSubject(Module::t('app', 'EMAIL_SIGNUP_SUBJECT') . Yii::$app->name)->send();
         }
         return $user;
     }
     return null;
 }
开发者ID:knyazushka,项目名称:z34lot.new,代码行数:28,代码来源:SignupForm.php


示例7: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $this->_user = User::findByUsername($this->username);
     }
     return $this->_user;
 }
开发者ID:head26,项目名称:parsek,代码行数:12,代码来源:LoginForm.php


示例8: testSignup

 public function testSignup(FunctionalTester $I)
 {
     $I->wantTo('ensure that signup works');
     $signupPage = SignupPage::openBy($I);
     $I->seeInTitle('Signup');
     $I->see('Please fill out the following fields to signup:');
     $I->amGoingTo('submit signup form with no data');
     $signupPage->submit([]);
     $I->expectTo('see validation errors');
     $I->see('Username cannot be blank.', '.help-block');
     $I->see('Email cannot be blank.', '.help-block');
     $I->see('Password cannot be blank.', '.help-block');
     $I->see('The verification code is incorrect.', '.help-block');
     $I->amGoingTo('submit signup form with not correct data');
     $signupPage->submit(['username' => 'tester', 'email' => 'tester.email', 'password' => 'tester_password', 'verifyCode' => 'wrong']);
     $I->expectTo('see that email address is wrong');
     $I->dontSee('Username cannot be blank.', '.help-block');
     $I->dontSee('Password cannot be blank.', '.help-block');
     $I->see('Email is not a valid email address.', '.help-block');
     $I->see('The verification code is incorrect.', '.help-block');
     $I->amGoingTo('submit signup form with correct data');
     $signupPage->submit(['username' => 'tester', 'email' => '[email protected]', 'password' => 'tester_password', 'verifyCode' => 'testme']);
     $I->expectTo('see that user is created');
     $I->seeRecord(User::className(), ['username' => 'tester', 'email' => '[email protected]', 'status' => User::STATUS_WAIT]);
     $I->expectTo('see that user signed in');
     $I->see('Please confirm your Email.', '.alert-success');
     $I->amGoingTo('confirm user email by token');
     /** @var User $user */
     $user = $I->grabRecord(User::className(), ['username' => 'tester']);
     EmailConfirmPage::openBy($I, ['token' => $user->email_confirm_token]);
     $I->expectTo('see that email is confirmed');
     $I->see('Thanks! Your Email is confirmed.', '.alert-success');
     $I->expectTo('see that user status is confirmed');
     $I->seeRecord(User::className(), ['username' => 'tester', 'email' => '[email protected]', 'status' => User::STATUS_ACTIVE, 'email_confirm_token' => null]);
 }
开发者ID:manakao,项目名称:melby,代码行数:35,代码来源:SignupCest.php


示例9: login

 /**
  * @return bool
  */
 public function login()
 {
     if ($this->validate()) {
         return User::login($this->email, $this->remember_me);
     }
     return false;
 }
开发者ID:vetoni,项目名称:toko,代码行数:10,代码来源:LoginForm.php


示例10: testPasswordReset

 /**
  * @after logout
  */
 public function testPasswordReset(FunctionalTester $I)
 {
     $I->wantTo('ensure that login works');
     $requestPage = PasswordResetRequestPage::openBy($I);
     $I->seeInTitle('Reset password');
     $I->amGoingTo('try to request with empty credentials');
     $requestPage->send('');
     $I->expectTo('see validations errors');
     $I->see('Email cannot be blank.');
     $I->amGoingTo('try to request with wrong credentials');
     $requestPage->send('reset-example.com');
     $I->expectTo('see validations errors');
     $I->see('Email is not a valid email address.');
     $I->amGoingTo('try to request with correct credentials');
     $requestPage->send('[email protected]');
     $I->expectTo('see user info');
     $I->see('Follow the link on mail to reset your password.', '.alert-success');
     $I->amGoingTo('open change password page by token');
     /** @var User $user */
     $user = $I->grabRecord(User::className(), ['email' => '[email protected]']);
     $resetPage = PasswordResetPage::openBy($I, ['token' => $user->password_reset_token]);
     $I->expectTo('see change password form');
     $I->see('Please choose your new password:');
     $I->amGoingTo('set new password');
     $resetPage->send('new-password');
     $I->expectTo('see password change success message');
     $I->see('Thanks! Your passwords is changed.');
     $I->amGoingTo('try to login with new credentials');
     $this->login($I, 'reset', 'new-password');
     $I->expectTo('see user info');
     $I->see('Profile');
 }
开发者ID:manakao,项目名称:melby,代码行数:35,代码来源:PasswordResetCest.php


示例11: 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


示例12: getUser

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


示例13: getUser

 /**
  * Finds user by id.
  *
  * @return User|null User instance
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $this->_user = User::find()->where(['id' => Yii::$app->user->identity->id])->active()->one();
     }
     return $this->_user;
 }
开发者ID:artkost,项目名称:yii2-starter-kit,代码行数:12,代码来源:Password.php


示例14: 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


示例15: 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


示例16: actionResult

 public function actionResult()
 {
     // $Shp_id= $user->PID;
     if (!Yii::$app->request->post()) {
         return $this->goBack();
     }
     $request = Yii::$app->request;
     $out_summ = $request->post('OutSum');
     $inv_id = $request->post('InvId');
     $shp_item = $request->post('Shp_item');
     $crc = $request->post('SignatureValue');
     $crc = strtoupper($crc);
     $my_crc = strtoupper(md5("{$out_summ}:{$inv_id}:{$this->mrh_pass2}:Shp_item={$shp_item}"));
     if ($my_crc != $crc) {
         throw new NotFoundHttpException('bad signature');
     }
     $user = User::findByPid($shp_item);
     $today = $user->date;
     if (date("Y-m-d") > $user->date) {
         $today = date("Y-m-d H:i:s");
     }
     $user->date = date('Y-m-d', strtotime($today . '+ 1 month'));
     $user->save();
     return "OK{$inv_id}\n";
 }
开发者ID:blacklis,项目名称:yiiserv,代码行数:25,代码来源:PaymentController.php


示例17: isValidToken

 /**
  * Check if token is valid.
  *
  * @return boolean true if token is valid
  */
 public function isValidToken()
 {
     if (SecurityHelper::isValidToken($this->token, Module::param('recoveryWithin', false)) === true) {
         return ($this->_user = User::findByToken($this->token, 'active')) !== null;
     }
     return false;
 }
开发者ID:artkost,项目名称:yii2-starter-kit,代码行数:12,代码来源:RecoveryConfirmation.php


示例18: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 private function getUser()
 {
     if ($this->user === false) {
         $this->user = User::findByUsername($this->username);
     }
     return $this->user;
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:12,代码来源:LoginForm.php


示例19: 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


示例20: getUser

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Repositories\UserRepository类代码示例发布时间:2022-05-23
下一篇:
PHP User\Module类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap