當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::className方法代碼示例

本文整理匯總了PHP中backend\models\User::className方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::className方法的具體用法?PHP User::className怎麽用?PHP User::className使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在backend\models\User的用法示例。


在下文中一共展示了User::className方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: register

 /**
  * Registers a new user account. If registration was successful it will set flash message.
  *
  * @return bool
  */
 public function register()
 {
     if (!$this->validate()) {
         return false;
     }
     /** @var User $user */
     $user = Yii::createObject(User::className());
     $user->setScenario('register');
     $this->loadAttributes($user);
     if (!$user->register()) {
         return false;
     }
     Yii::$app->session->setFlash('info', Yii::t('user', 'Your account has been created and a message with further instructions has been sent to your email'));
     return true;
 }
開發者ID:apmauj,項目名稱:1f8bf10ab74d6f5ca69f7c07b7ee1c38,代碼行數:20,代碼來源:RegistrationForm.php

示例2: actionConnect

 /**
  * Displays page where user can create new account that will be connected to social account.
  *
  * @param string $code
  *
  * @return string
  * @throws NotFoundHttpException
  */
 public function actionConnect($code)
 {
     $account = $this->finder->findAccount()->byCode($code)->one();
     if ($account === null || $account->getIsConnected()) {
         throw new NotFoundHttpException();
     }
     /** @var User $user */
     $user = Yii::createObject(['class' => User::className(), 'scenario' => 'connect', 'username' => $account->username, 'email' => $account->email]);
     if ($user->load(Yii::$app->request->post()) && $user->create()) {
         $account->connect($user);
         return $this->render('/message', ['title' => Yii::t('user', 'Your account has been created'), 'module' => $this->module]);
         //            Yii::$app->user->login($user, $this->module->rememberFor);
         //            return $this->goBack();
     }
     return $this->render('connect', ['model' => $user, 'account' => $account]);
 }
開發者ID:apmauj,項目名稱:1f8bf10ab74d6f5ca69f7c07b7ee1c38,代碼行數:24,代碼來源:RegistroController.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()
 {
     $user = Yii::createObject(['class' => User::className(), 'scenario' => 'create']);
     if ($user->load(Yii::$app->request->post())) {
         /*            $coordenadas = sysconfigs::getCoordinates($user->direccion);
                     $user->latitud = $coordenadas['latitud'];
                     $user->longitud = $coordenadas['longitud'];*/
         //generamos password
         $user->password = $user->password == null ? Password::generate(8) : $user->password;
         if ($user->save()) {
             $user->mailer->sendWelcomeMessage($user, null);
             return $this->redirect(['update', 'id' => $user->id]);
         } else {
             return $this->render('create', ['user' => $user]);
         }
     } else {
         return $this->render('create', ['user' => $user]);
     }
 }
開發者ID:apmauj,項目名稱:1f8bf10ab74d6f5ca69f7c07b7ee1c38,代碼行數:24,代碼來源:AdminController.php

示例4: rules

 public function rules()
 {
     return [[['username', 'email', 'password'], 'filter', 'filter' => 'trim'], [['username', 'email', 'password'], 'required'], ['username', 'string', 'min' => 2, 'max' => 255], ['password', 'string', 'min' => 6, 'max' => 255], ['username', 'unique', 'targetClass' => User::className(), 'message' => 'Это имя уже занято.'], ['email', 'email'], ['email', 'unique', 'targetClass' => User::className(), 'message' => 'Эта почта уже занята.'], ['status', 'default', 'value' => User::STATUS_ACTIVE, 'on' => 'default'], ['status', 'in', 'range' => [User::STATUS_NOT_ACTIVE, User::STATUS_ACTIVE]]];
 }
開發者ID:GalkinDmitriy,項目名稱:evalotta,代碼行數:4,代碼來源:RegForm.php

示例5: getUser

 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(User::className(), ['id' => 'user_id']);
 }
開發者ID:nym3ny,項目名稱:westwolf,代碼行數:7,代碼來源:Tasks.php

示例6: getUser

 public function getUser()
 {
     return $this->hasMany(User::className(), ['level_id' => 'level_id']);
 }
開發者ID:rxz135cc,項目名稱:yii2webApp,代碼行數:4,代碼來源:Level.php

示例7: dirname

<?php

use backend\models\User;
$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
return ['id' => 'app-backend', 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'backend\\controllers', 'aliases' => ['@file_view_dir' => '@backend/files'], 'bootstrap' => ['log'], 'modules' => [], 'components' => ['user' => ['identityClass' => User::className(), 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error']], 'params' => $params];
開發者ID:brygom,項目名稱:yii2-advanced-template-rbac,代碼行數:5,代碼來源:backend.php

示例8: getAuthor

 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthor()
 {
     return $this->hasOne(User::className(), ['id' => 'author_id']);
 }
開發者ID:mahmoodkhoeini,項目名稱:yii2cms,代碼行數:7,代碼來源:Post.php

示例9: getUsers

 /**
 * @return \yii\db\ActiveQuery
 */
 public function getUsers()
 {
     return $this->hasMany(User::className(), ['role_id' => 'role_value']);
 }
開發者ID:Ksenomorfa,項目名稱:yii2advanced,代碼行數:7,代碼來源:Role.php

示例10: getUsers

 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUsers()
 {
     return $this->hasMany(User::className(), ['attendee_id' => 'id']);
 }
開發者ID:Rakeshdrupal,項目名稱:yiifirstliveproject,代碼行數:7,代碼來源:AmgenContactList.php

示例11: getAddress

 public function getAddress()
 {
     return $this->hasOne(User::className(), ['id' => 'addressId']);
 }
開發者ID:jaybril,項目名稱:www.mimgpotea.com,代碼行數:4,代碼來源:Order.php

示例12: getIdUsuario

 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdUsuario()
 {
     return $this->hasOne(User::className(), ['id' => 'id_usuario']);
 }
開發者ID:apmauj,項目名稱:1f8bf10ab74d6f5ca69f7c07b7ee1c38,代碼行數:7,代碼來源:Ruta.php

示例13: getCreatedBy

 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCreatedBy()
 {
     return $this->hasOne(User::className(), ['id' => 'created_by']);
 }
開發者ID:vihanga-liyanage,項目名稱:feed-cloud,代碼行數:7,代碼來源:Module.php

示例14: getUsername0

 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUsername0()
 {
     return $this->hasOne(User::className(), ['username' => 'username']);
 }
開發者ID:quyettvq,項目名稱:luspel,代碼行數:7,代碼來源:UserLog.php

示例15: getUsers

 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUsers()
 {
     return $this->hasMany(User::className(), ['id' => 'user_id'])->viaTable('auth_assignment', ['item_name' => 'name']);
 }
開發者ID:havoe,項目名稱:doingiteasy,代碼行數:7,代碼來源:AuthItem.php


注:本文中的backend\models\User::className方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。