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


PHP User::getId方法代码示例

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


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

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

示例2: signup

 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $profile = new Profile();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $user->role = 'user';
         $user->status = 1;
         $profile->firstname = $this->firstname;
         $profile->lastname = $this->lastname;
         $profile->avatar = $this->avatar;
         // $profile->gender = 0;
         $transaction = Yii::$app->db->beginTransaction();
         if ($user->save()) {
             $profile->user_id = $user->getId();
             if ($profile->save()) {
                 $transaction->commit();
                 return $user;
             }
         } else {
             $transaction->rollback();
             print_r($user->getErrors());
             return false;
         }
     }
     return null;
 }
开发者ID:akula22,项目名称:fifa,代码行数:35,代码来源:SignupForm.php

示例3: 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->status = User::STATUS_WAIT;
         $user->generateAuthKey();
         $user->generateEmailConfirmToken();
         //
         if ($user->save()) {
             $auth = Yii::$app->authManager;
             $role = $auth->getRole('client');
             $auth->assign($role, $user->getId());
             $confirmLink = Yii::$app->urlManager->createAbsoluteUrl(['user/default/confirm-email', 'token' => $user->email_confirm_token]);
             $message = "Здравствуйте, " . Html::encode($user->username) . "!";
             $message .= "Для подтверждения адреса пройдите по ссылке:";
             //$message .= Html::a(Html::encode($confirmLink), $confirmLink) ;
             $message .= $confirmLink;
             $message .= " Если Вы не регистрировались у на нашем сайте, то просто удалите это письмо.";
             // Отправляем
             mail($user->email, 'Регистрация на сайте', $message);
             //                $mailer =Yii::$app->get('mailsmtp');
             //
             //                $message =$mailer->compose('confirmEmail', ['user' => $user])
             //
             //                    ->setTo($this->email)
             //                    ->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])
             //                    ->setSubject('Email confirmation for ' . Yii::$app->name);
             //
             //                $message->getSwiftMessage()->getHeaders()->addTextHeader('name', 'value');
             //                $failures =null;
             //                try {
             //
             //                    if(!$mailer->send($message, $failures)) $errorCode=$failures; //отправляем
             //
             //                }catch (\Swift_TransportException $e) { //проверяем на ошибки
             //                    $pattern = '|got code "(.+?)", with|is';
             //                    preg_match($pattern, $e->getMessage(), $out);
             //                    $errorCode=$out[1];
             //                }
             /*Yii::$app->mailer->compose('confirmEmail', ['user' => $user])
               ->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])
               ->setTo($this->email)
               ->setSubject('Email confirmation for ' . Yii::$app->name)
               ->send();*/
         }
         return $user;
     }
     return null;
 }
开发者ID:kvaxminsk,项目名称:evo8,代码行数:57,代码来源:SignupForm.php

示例4: actionCreate

 public function actionCreate()
 {
     $user = new User(['scenario' => 'admin-create']);
     $profile = new Profile();
     $statusArray = User::getStatusArray();
     $roleArray = User::getRoleArray();
     if ($user->load(Yii::$app->request->post())) {
         if ($user->validate()) {
             $transaction = Yii::$app->db->beginTransaction();
             if ($user->save(false)) {
                 $profile->user_id = $user->getId();
                 if ($profile->save(false)) {
                     $transaction->commit();
                     return $this->redirect(['index']);
                 } else {
                     $transaction->rollback();
                     print_r($user->getErrors());
                     return false;
                 }
             } else {
                 Yii::$app->session->setFlash('danger', 'Ошибка');
                 return $this->refresh();
             }
         }
     }
     // $transaction = Yii::$app->db->beginTransaction();
     //     if ($user->save())
     //     {
     //         $profile->user_id = $user->getId();
     //         if($profile->save())
     //         {
     //             $transaction->commit();
     //             return $user;
     //         }
     //     }
     //     else
     //     {
     //         $transaction->rollback();
     //         print_r($user->getErrors());
     //         return false;
     //     }
     return $this->render('create', ['model' => $user, 'statusArray' => $statusArray, 'roleArray' => $roleArray]);
 }
开发者ID:akula22,项目名称:fifa,代码行数:43,代码来源:BackendController.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->status = User::STATUS_WAIT;
         $user->generateAuthKey();
         $user->generateEmailConfirmToken();
         if ($user->save()) {
             $auth = Yii::$app->authManager;
             $authorRole = $auth->getRole('author');
             $auth->assign($authorRole, $user->getId());
             Yii::$app->mailer->compose(['text' => '@app/modules/user/mails/emailConfirm'], ['user' => $user])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])->setTo($this->email)->setSubject('Email confirmation for ' . Yii::$app->name)->send();
         }
         return $user;
     }
     return null;
 }
开发者ID:loop69,项目名称:yii2-rabbit-burrow,代码行数:25,代码来源:SignupForm.php


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