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


PHP User::className方法代码示例

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


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

示例1: runGet

 private function runGet()
 {
     $request = Yii::$app->getRequest();
     $model = DynamicModel::validateData(['id' => $request->get('id'), 'screen_name' => $request->get('screen_name'), 'count' => $request->get('count'), 'newer_than' => $request->get('newer_than'), 'older_than' => $request->get('older_than')], [[['id'], 'exist', 'targetClass' => Battle::className(), 'targetAttribute' => 'id'], [['screen_name'], 'exist', 'targetClass' => User::className(), 'targetAttribute' => 'screen_name'], [['newer_than', 'older_than'], 'integer'], [['count'], 'default', 'value' => 10], [['count'], 'integer', 'min' => 1, 'max' => 100]]);
     if (!$model->validate()) {
         return $this->formatError($model->getErrors(), 400);
     }
     $query = Battle::find()->innerJoinWith('user')->with(['user', 'user.userStat', 'lobby', 'rule', 'map', 'weapon', 'weapon.subweapon', 'weapon.special', 'rank', 'battleImageResult', 'battleImageJudge'])->orderBy('{{battle}}.[[id]] DESC')->limit((int) $model->count);
     if ($model->id != '') {
         $query->andWhere(['{{battle}}.[[id]]' => $model->id]);
     }
     if ($model->screen_name != '') {
         $query->andWhere(['{{user}}.[[screen_name]]' => $model->screen_name]);
     }
     if ($model->newer_than > 0) {
         $query->andWhere(['>', '{{battle}}.[[id]]', $model->newer_than]);
     }
     if ($model->older_than > 0) {
         $query->andWhere(['<', '{{battle}}.[[id]]', $model->older_than]);
     }
     $list = $query->all();
     if ($model->id != '') {
         return empty($list) ? null : $this->runGetImpl(array_shift($list));
     }
     $resp = Yii::$app->getResponse();
     $resp->format = 'json';
     return array_map(function ($model) {
         return $model->toJsonArray();
     }, $list);
 }
开发者ID:Bochozkar,项目名称:stat.ink,代码行数:30,代码来源:BattleAction.php

示例2: rules

 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['follower_id', 'following_id'], 'required'], [['follower_id', 'following_id', 'create_date'], 'integer'], [['follower_id'], 'compare', 'compareAttribute' => 'following_id', 'operator' => '!='], [['following_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['following_id' => 'id']], [['follower_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['follower_id' => 'id']], [['follower_id'], function ($attribute, $params) {
         $count = self::find()->where(self::tableName() . '.following_id = :attr1 OR ' . self::tableName() . '.follower_id = :attr2')->orWhere(self::tableName() . '.following_id = :attr2 OR ' . self::tableName() . '.follower_id = :attr1')->params([':attr1' => $this->{$attribute}, ':attr2' => $this->following_id])->count();
         return $count == 0;
     }]];
 }
开发者ID:artpro676,项目名称:twitter,代码行数:10,代码来源:Relation.php

示例3: rules

 public function rules()
 {
     $rules = [[['screen_name', 'password', 'password_repeat'], 'required'], [['screen_name'], 'string', 'max' => 15], [['screen_name'], 'match', 'pattern' => '/^[a-zA-Z0-9_]{1,15}$/', 'message' => '{attribute} must be at most 15 alphanumeric or underscore characters.'], [['screen_name'], 'unique', 'targetClass' => User::className(), 'message' => Yii::t('app', 'This {attribute} is already in use.')], [['name'], 'string', 'max' => 15], [['password_repeat'], 'compare', 'compareAttribute' => 'password', 'operator' => '===']];
     if (Yii::$app->params['googleRecaptcha']['siteKey'] != '') {
         $rules[] = [['recaptcha_token', 'recaptcha_response'], 'required', 'message' => Yii::t('app', 'Please check the reCAPTCHA.')];
         $rules[] = [[], ReCaptchaValidator::className(), 'secret' => Yii::$app->params['googleRecaptcha']['secret']];
     }
     return $rules;
 }
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:9,代码来源:RegisterForm.php

示例4: rules

 public function rules()
 {
     $rules = [[['screen_name', 'password'], 'required'], [['screen_name'], 'string', 'max' => 15], [['screen_name'], 'match', 'pattern' => '/^[a-zA-Z0-9_]{1,15}$/', 'message' => 'ログイン名は英数とアンダーバーの15文字以内で決めてください'], [['screen_name'], 'unique', 'targetClass' => User::className(), 'message' => 'このログイン名は既に使用されています'], [['name'], 'string', 'max' => 15]];
     if (Yii::$app->params['googleRecaptcha']['siteKey'] != '') {
         $rules[] = [['recaptcha_token', 'recaptcha_response'], 'required', 'message' => 'reCAPTCHAの確認をしてください'];
         $rules[] = [[], ReCaptchaValidator::className(), 'secret' => Yii::$app->params['googleRecaptcha']['secret']];
     }
     return $rules;
 }
开发者ID:hasegaw,项目名称:IkaLogLog,代码行数:9,代码来源:RegisterForm.php

示例5: actionDelete

 /**
  * @param $id
  * @return void|array
  * @throws \Exception
  */
 public function actionDelete($id)
 {
     //TODO: Check rights
     if (!User::find()->where(['id' => $id])->limit(1)->one()->delete()) {
         \Yii::$app->response->setStatusCode(404);
         return ErrorMessage::ModelNotFound(User::className(), $id);
     }
     \Yii::$app->response->setStatusCode(204);
 }
开发者ID:JiltImageBoard,项目名称:jilt-backend,代码行数:14,代码来源:UserController.php

示例6: actionDelete

 /**
  * Delete user action.
  * @param integer $id user id
  * @since 0.2
  */
 public function actionDelete($id)
 {
     /** @var $user UserModel */
     $user = $this->findModel(UserModel::className(), $id);
     if ($user->delete()) {
         $this->addFlash(self::FLASH_SUCCESS, Yii::t('app', 'User <b>{name}</b> deleted.', ['name' => Html::encode($user->name)]));
     }
     return $this->redirect(['index']);
 }
开发者ID:skoro,项目名称:yii2-admin-template,代码行数:14,代码来源:UserController.php

示例7: actionCreate

 public function actionCreate()
 {
     /** @var User $user */
     $user = \Yii::createObject(['class' => User::className(), 'scenario' => 'create']);
     $this->performAjaxValidation($user);
     if ($user->load(\Yii::$app->request->post()) && $user->create()) {
         \Yii::$app->getSession()->setFlash('success', \Yii::t('user', 'User has been created'));
         return $this->redirect(['update', 'id' => $user->id]);
     }
     return $this->render('create', ['user' => $user]);
 }
开发者ID:roman1970,项目名称:lis,代码行数:11,代码来源:AdminController.php

示例8: rules

 public function rules()
 {
     return [[['apikey'], 'required'], [['apikey'], 'exist', 'targetClass' => User::className(), 'targetAttribute' => 'api_key'], [['lobby'], 'exist', 'targetClass' => Lobby::className(), 'targetAttribute' => 'key'], [['rule'], 'exist', 'targetClass' => Rule::className(), 'targetAttribute' => 'key'], [['map'], 'exist', 'targetClass' => Map::className(), 'targetAttribute' => 'key'], [['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key'], [['rank', 'rank_after'], 'exist', 'targetClass' => Rank::className(), 'targetAttribute' => 'key'], [['rank_exp', 'rank_exp_after'], 'integer', 'min' => 0, 'max' => 99], [['level', 'level_after'], 'integer', 'min' => 1, 'max' => 50], [['result'], 'boolean', 'trueValue' => 'win', 'falseValue' => 'lose'], [['cash', 'cash_after'], 'integer', 'min' => 0, 'max' => 9999999], [['rank_in_team'], 'integer', 'min' => 1, 'max' => 4], [['kill', 'death'], 'integer', 'min' => 0], [['death_reasons'], 'validateDeathReasons'], [['fest_gender'], 'in', 'range' => ['boy', 'girl']], [['fest_rank'], 'filter', 'filter' => 'strtolower'], [['fest_rank'], 'exist', 'targetClass' => FestTitle::className(), 'targetAttribute' => 'key'], [['my_team_color', 'his_team_color'], 'validateTeamColor'], [['image_judge', 'image_result'], 'safe'], [['image_judge', 'image_result'], 'file', 'maxSize' => 3 * 1024 * 1024, 'when' => function ($model, $attr) {
         return !is_string($model->{$attr});
     }], [['image_judge', 'image_result'], 'validateImageFile', 'when' => function ($model, $attr) {
         return !is_string($model->{$attr});
     }], [['image_judge', 'image_result'], 'validateImageString', 'when' => function ($model, $attr) {
         return is_string($model->{$attr});
     }], [['start_at', 'end_at'], 'integer'], [['agent'], 'string', 'max' => 64], [['agent_version'], 'string', 'max' => 255], [['agent', 'agent_version'], 'required', 'when' => function ($model, $attr) {
         return (string) $this->agent !== '' || (string) $this->agent_version !== '';
     }], [['my_point'], 'integer', 'min' => 0], [['my_team_final_point', 'his_team_final_point'], 'integer', 'min' => 0], [['my_team_final_percent', 'his_team_final_percent'], 'number', 'min' => 0.0, 'max' => 100.0], [['knock_out'], 'boolean', 'trueValue' => 'yes', 'falseValue' => 'no'], [['my_team_count', 'his_team_count'], 'integer', 'min' => 0, 'max' => 100], [['lobby'], 'fixLobby']];
 }
开发者ID:ExceptionError,项目名称:stat.ink,代码行数:12,代码来源:PostBattleForm.php

示例9: rules

 public function rules()
 {
     return [[['screen_name'], 'exist', 'targetClass' => User::className(), 'targetAttribute' => 'screen_name'], [['lobby'], 'exist', 'targetClass' => Lobby::className(), 'targetAttribute' => 'key'], [['rule'], 'exist', 'targetClass' => Rule::className(), 'targetAttribute' => 'key', 'when' => function () {
         return substr($this->rule, 0, 1) !== '@';
     }], [['rule'], 'validateGameMode', 'when' => function () {
         return substr($this->rule, 0, 1) === '@';
     }], [['map'], 'exist', 'targetClass' => Map::className(), 'targetAttribute' => 'key'], [['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key', 'when' => function () {
         return !in_array(substr($this->weapon, 0, 1), ['@', '+', '*'], true);
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => WeaponType::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '@';
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Subweapon::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '+';
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Special::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '*';
     }], [['result'], 'boolean', 'trueValue' => 'win', 'falseValue' => 'lose'], [['term'], 'in', 'range' => ['this-period', 'last-period', '24h', 'today', 'yesterday', 'term']], [['term_from', 'term_to'], 'date', 'format' => 'yyyy-M-d H:m:s']];
 }
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:16,代码来源:BattleFilterForm.php

示例10: rules

 public function rules()
 {
     return [[['screen_name'], 'exist', 'targetClass' => User::className(), 'targetAttribute' => 'screen_name'], [['rule'], 'exist', 'targetClass' => Rule::className(), 'targetAttribute' => 'key', 'when' => function () {
         return substr($this->rule, 0, 1) !== '@';
     }], [['rule'], 'validateGameMode', 'when' => function () {
         return substr($this->rule, 0, 1) === '@';
     }], [['map'], 'exist', 'targetClass' => Map::className(), 'targetAttribute' => 'key'], [['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key', 'when' => function () {
         return !in_array(substr($this->weapon, 0, 1), ['@', '+', '*'], true);
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => WeaponType::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '@';
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Subweapon::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '+';
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Special::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '*';
     }], [['result'], 'boolean', 'trueValue' => 'win', 'falseValue' => 'lose']];
 }
开发者ID:ExceptionError,项目名称:stat.ink,代码行数:16,代码来源:BattleFilterForm.php

示例11: actionChangePassword

 /**
  * Action change user password.
  * @return string|\yii\web\Response
  * @throws \yii\web\NotFoundHttpException
  * @author Alex Makhorin
  */
 public function actionChangePassword()
 {
     /** @var User $model */
     $model = $this->findModel(User::className(), Yii::$app->user->identity->getId());
     $passwordForm = new PasswordForm();
     if ($passwordForm->load(Yii::$app->request->post())) {
         $passwordForm->userId = Yii::$app->user->identity->getId();
         if ($passwordForm->validate()) {
             $model->password = $passwordForm->new;
             if ($model->save(false)) {
                 Yii::$app->getSession()->setFlash('success', ['body' => Yii::t('app', 'Password changed')]);
                 return $this->redirect(['profile']);
             } else {
                 Yii::$app->getSession()->setFlash('danger', ['body' => Yii::t('app', 'Password not changed')]);
                 return $this->redirect(['profile']);
             }
         }
     }
     return $this->renderAjax('partials/_changePasswordModal', ['model' => $passwordForm]);
 }
开发者ID:vfokov,项目名称:tims2,代码行数:26,代码来源:DefaultController.php

示例12: rules

 public function rules()
 {
     return [[['apikey'], 'required'], [['apikey'], 'exist', 'targetClass' => User::className(), 'targetAttribute' => 'api_key'], [['test'], 'in', 'range' => ['validate', 'dry_run']], [['lobby'], 'exist', 'targetClass' => Lobby::className(), 'targetAttribute' => 'key'], [['rule'], 'exist', 'targetClass' => Rule::className(), 'targetAttribute' => 'key'], [['map'], 'exist', 'targetClass' => Map::className(), 'targetAttribute' => 'key'], [['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key'], [['rank', 'rank_after'], 'exist', 'targetClass' => Rank::className(), 'targetAttribute' => 'key'], [['rank_exp', 'rank_exp_after'], 'integer', 'min' => 0, 'max' => 99], [['level', 'level_after'], 'integer', 'min' => 1, 'max' => 50], [['result'], 'boolean', 'trueValue' => 'win', 'falseValue' => 'lose'], [['cash', 'cash_after'], 'integer', 'min' => 0, 'max' => 9999999], [['rank_in_team'], 'integer', 'min' => 1, 'max' => 4], [['kill', 'death'], 'integer', 'min' => 0], [['death_reasons'], 'validateDeathReasons'], [['gender'], 'in', 'range' => ['boy', 'girl']], [['fest_title', 'fest_title_after'], 'filter', 'filter' => 'strtolower'], [['fest_title', 'fest_title_after'], 'filter', 'filter' => function ($a) {
         switch ($a) {
             case 'campion':
                 return 'champion';
             case 'friend':
                 return 'fiend';
             default:
                 return $a;
         }
     }], [['fest_title', 'fest_title_after'], 'exist', 'targetClass' => FestTitle::className(), 'targetAttribute' => 'key'], [['fest_exp', 'fest_exp_after'], 'integer', 'min' => 0, 'max' => 99], [['my_team_color', 'his_team_color'], 'validateTeamColor'], [['image_judge', 'image_result'], 'safe'], [['image_judge', 'image_result'], 'file', 'maxSize' => 3 * 1024 * 1024, 'when' => function ($model, $attr) {
         return !is_string($model->{$attr});
     }], [['image_judge', 'image_result'], 'validateImageFile', 'when' => function ($model, $attr) {
         return !is_string($model->{$attr});
     }], [['image_judge', 'image_result'], 'validateImageString', 'when' => function ($model, $attr) {
         return is_string($model->{$attr});
     }], [['start_at', 'end_at'], 'integer'], [['agent'], 'string', 'max' => 64], [['agent_version'], 'string', 'max' => 255], [['agent', 'agent_version'], 'required', 'when' => function ($model, $attr) {
         return (string) $this->agent !== '' || (string) $this->agent_version !== '';
     }], [['agent_custom'], 'string'], [['agent', 'agent_version', 'agent_custom'], 'validateStrictUTF8'], [['automated'], 'boolean', 'trueValue' => 'yes', 'falseValue' => 'no'], [['automated'], 'estimateAutomatedAgent', 'skipOnEmpty' => false], [['my_point'], 'integer', 'min' => 0], [['my_team_final_point', 'his_team_final_point'], 'integer', 'min' => 0], [['my_team_final_percent', 'his_team_final_percent'], 'number', 'min' => 0.0, 'max' => 100.0], [['knock_out'], 'boolean', 'trueValue' => 'yes', 'falseValue' => 'no'], [['my_team_count', 'his_team_count'], 'integer', 'min' => 0, 'max' => 100], [['players'], 'validatePlayers'], [['gears'], 'validateGears'], [['events'], 'validateEvents']];
 }
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:21,代码来源:PostBattleForm.php

示例13: getUsers

 /**
  *  
  *
  * @return mixed
 */
 public function getUsers()
 {
     return $this->hasOne(User::className(), ['tocken' => 'tocken']);
 }
开发者ID:kansey,项目名称:yii2albom,代码行数:9,代码来源:Images.php

示例14: rules

 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [['name', 'required'], ['name', 'filter', 'filter' => 'trim'], ['name', 'string', 'min' => 2, 'max' => 255], ['email', 'filter', 'filter' => 'trim'], ['email', 'required'], ['email', 'email'], ['email', 'unique', 'targetClass' => User::className(), 'message' => __('This email address has already been taken.')], ['password', 'required'], ['password', 'string', 'min' => static::PASS_MIN_LEN]];
 }
开发者ID:vsguts,项目名称:crm,代码行数:7,代码来源:UserSignupForm.php

示例15: actions

 public function actions()
 {
     return array_merge(parent::actions(), ['editable' => ['class' => EditableAction::className(), 'modelClass' => User::className(), 'forceCreate' => false]]);
 }
开发者ID:NewPaltzKarateAcademy,项目名称:KIMS,代码行数:4,代码来源:UserController.php


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