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


PHP User::getId方法代码示例

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


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

示例1: testSetGetIdMethods

 public function testSetGetIdMethods()
 {
     $expected = 10;
     $user = new User();
     $user->setId($expected);
     $this->assertEquals($expected, $user->getId());
 }
开发者ID:Everus,项目名称:wbftest,代码行数:7,代码来源:UserTest.php

示例2: userCreateOrUpdate

 public function userCreateOrUpdate(User $user)
 {
     if (false == env('INTERCOM_ENABLED')) {
         return false;
     }
     $user_data = ['user_id' => $user->getId(), 'email' => $user->email, 'last_request_at' => time(), 'custom_attributes' => ['username' => $user->username, 'first_name' => $user->first_name, 'last_name' => $user->last_name]];
     $this->intercom->updateUser($user_data, true);
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:8,代码来源:Intercom.php

示例3: userCreateOrUpdate

 protected function userCreateOrUpdate(User $user, $type)
 {
     if (false == env('MIXPANEL_ENABLED')) {
         return false;
     }
     $this->mixpanel->setIdentity($user->getId());
     $this->mixpanel->setIp($this->getIp());
     $this->mixpanel->addTrackEvent($type, ['created_at' => time(), 'username' => $user->username, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'email' => $user->email]);
     $this->mixpanel->addUserEvent('set', $type, ['$email' => $user->email, '$username' => $user->username, '$first_name' => $user->first_name, '$last_name' => $user->last_name]);
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:10,代码来源:Mixpanel.php

示例4: 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->name = $this->name;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $user->save(false);
         Yii::$app->authManager->assign(Yii::$app->authManager->getRole('user'), $user->getId());
         return $user;
     }
     return null;
 }
开发者ID:Sywooch,项目名称:notes,代码行数:19,代码来源:SignupForm.php

示例5: signup

 /**
  * Signs up the user.
  * If scenario is set to "rna" (registration needs activation), this means
  * that user need to activate his account using email confirmation method.
  *
  * @return User|null The saved model or null if saving fails.
  */
 public function signup()
 {
     $user = new User();
     $user->username = $this->username;
     $user->email = $this->email;
     $user->setPassword($this->password);
     $user->generateAuthKey();
     $user->status = $this->status;
     // if scenario is "rna" we will generate account activation token
     if ($this->scenario === 'rna') {
         $user->generateAccountActivationToken();
     }
     // if user is saved and role is assigned return user object
     return $user->save() && RbacHelper::assignRole($user->getId()) ? $user : null;
 }
开发者ID:elevatesolutions,项目名称:proverbs,代码行数:22,代码来源:SignupForm.php

示例6: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @return string|\yii\web\Response
  */
 public function actionCreate()
 {
     $user = new User(['scenario' => 'create']);
     $role = new Role();
     if ($user->load(Yii::$app->request->post()) && $role->load(Yii::$app->request->post()) && Model::validateMultiple([$user, $role])) {
         $user->setPassword($user->password);
         $user->generateAuthKey();
         if ($user->save()) {
             $role->user_id = $user->getId();
             $role->save();
         }
         return $this->redirect('index');
     } else {
         return $this->render('create', ['user' => $user, 'role' => $role]);
     }
 }
开发者ID:kamatchipannerselvam,项目名称:yii2,代码行数:22,代码来源:UserController.php

示例7: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @return string|\yii\web\Response
  */
 public function actionCreate()
 {
     $user = new User(['scenario' => 'create']);
     $role = new Role();
     if ($user->load(Yii::$app->request->post()) && $role->load(Yii::$app->request->post()) && Model::validateMultiple([$user, $role])) {
         $user->setPassword($user->password);
         $user->generateAuthKey();
         if ($user->save()) {
             $role->user_id = $user->getId();
             $role->save();
         }
         Yii::$app->session->setFlash('success', implode(' ', [ucfirst($user->username), ' successfully created!']));
         return $this->redirect('index');
     } else {
         return $this->render('create', ['user' => $user, 'role' => $role]);
     }
 }
开发者ID:elevatesolutions,项目名称:proverbs,代码行数:23,代码来源:UserController.php

示例8: 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()) {
             $auth = Yii::$app->authManager;
             $authorRole = $auth->getRole('author');
             $auth->assign($authorRole, $user->getId());
             return $user;
         }
     }
     return null;
 }
开发者ID:ari633,项目名称:fundnel-tech-test-aripratomo,代码行数:22,代码来源:SignupForm.php

示例9: reg

 public function reg()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->status = $this->status;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($this->scenario === 'emailActivation') {
             $user->generateSecretKey();
         }
         $user->save();
         $auth = Yii::$app->authManager;
         $simpleUser = $auth->getRole('simpleUser');
         $auth->assign($simpleUser, $user->getId());
         return $user;
     }
 }
开发者ID:Ramengel,项目名称:yii_fl,代码行数:19,代码来源:RegForm.php

示例10: reg

 public function reg()
 {
     $user = new User();
     $user->username = $this->username;
     $user->email = $this->email;
     $user->setPassword($this->password);
     $user->generateAuthKey();
     $user->create_at = time();
     if ($this->scenario === 'emailActivation') {
         $user->generateSecretKey();
     }
     if ($user->save()) {
         $userRole = Yii::$app->authManager->getRole('pay');
         Yii::$app->authManager->assign($userRole, $user->getId());
         return $user;
     } else {
         return null;
     }
 }
开发者ID:dosh93,项目名称:shop,代码行数:19,代码来源:RegForm.php

示例11: findByUser

 /**
  * Finds a throttler by the given Model.
  *
  * @param \App\Models\User $user
  * @param string $ipAddress
  *
  * @return \App\Models\Throttle
  */
 public function findByUser($user, $ipAddress = null)
 {
     $model = $this->model;
     $query = $model->query()->where('user_id', '=', $userId = $user->getId());
     if ($ipAddress) {
         $query->where(function ($query) use($ipAddress) {
             $query->where('ip_address', '=', $ipAddress);
             $query->orWhere('ip_address', '=', null);
         });
     }
     if (!($throttle = $query->first())) {
         $throttle = $this->model;
         $throttle->user_id = $userId;
         if ($ipAddress) {
             $throttle->ip_address = $ipAddress;
         }
         $throttle->save();
     }
     return $throttle;
 }
开发者ID:spetross,项目名称:ugvoice,代码行数:28,代码来源:ThrottleRepository.php

示例12: 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->status = User::STATUS_WAIT;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $user->generateEmailConfirmToken();
         if ($user->save()) {
             $auth = Yii::$app->authManager;
             $role = $auth->getRole('author');
             $auth->assign($role, $user->getId());
             Yii::$app->session->setFlash('success', 'bilo vislanno pismo dlya  pottverjdeniya regi');
             Yii::$app->mailer->compose(['html' => 'emailConfirm-html', 'text' => 'emailConfirm-text'], ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Account confirmation for ' . \Yii::$app->name)->send();
             return $user;
         }
     }
     return null;
 }
开发者ID:mirtovsh,项目名称:basic,代码行数:26,代码来源:SignupForm.php

示例13: registrations

 public function registrations($link)
 {
     $data = time();
     $user = new User();
     $user->username = $this->username;
     $user->password = '';
     $user->generateAuthKey();
     $user->u_snp = $this->name;
     $user->u_company = $this->company;
     $user->u_status = 0;
     $user->u_activation_link = $link;
     $user->u_time_link = $data;
     $user->date_post = $data;
     $user->update_post = $data;
     $check = $user->save() ? $user : null;
     // нужно добавить следующие три строки:
     $auth = Yii::$app->authManager;
     $authorRole = $auth->getRole('user');
     $auth->assign($authorRole, $user->getId());
     return $check;
     // сохраняем нового пользователя, если все ок то тру, елсе фолс
 }
开发者ID:BohdanYarema,项目名称:InternetSolutions,代码行数:22,代码来源:Registration.php

示例14: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (Yii::$app->user->can('user')) {
         $model = new User();
         $model->generateAuthKey();
         $model->create_at = time();
         $roles = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description');
         $user_permit = array_keys(Yii::$app->authManager->getRolesByUser($model->id));
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             Yii::$app->authManager->revokeAll($model->getId());
             if (Yii::$app->request->post('role')) {
                 foreach (Yii::$app->request->post('role') as $role) {
                     $new_role = Yii::$app->authManager->getRole($role);
                     Yii::$app->authManager->assign($new_role, $model->getId());
                 }
             }
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model, 'roles' => $roles, 'user_permit' => $user_permit]);
         }
     } else {
         Yii::$app->session->setFlash('error', 'Нет доступа!');
         $this->redirect('/');
     }
 }
开发者ID:dosh93,项目名称:shop,代码行数:30,代码来源:UserController.php

示例15: getUserData

 /**
  * @param \app\models\User $user
  * @return array
  * [
  *      'id' => идентификатор пользователя
  *      'name' => Имя и фамилия
  *      'avatar' => '/' относительный путь к аватару
  * ]
  */
 public function getUserData($user)
 {
     return ['id' => $user->getId(), 'name' => $user->getField('name_first') . ' ' . $user->getField('name_last'), 'avatar' => $user->getAvatar()];
 }
开发者ID:Makeyko,项目名称:galaxysss,代码行数:13,代码来源:UsersInCache.php


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