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


PHP User::findOne方法代码示例

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


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

示例1: validateCurrentPassword

 public function validateCurrentPassword($attribute)
 {
     if (!empty($this->user_id)) {
         $user = User::findOne($this->user_id);
         if (!$user->validatePassword($this->current_password)) {
             $this->addError($attribute, Yii::t('podium/view', 'Current password is incorrect.'));
         }
     }
 }
开发者ID:keltstr,项目名称:yii2-podium,代码行数:9,代码来源:Meta.php

示例2: actionView

 /**
  * Listing the details of user of given ID.
  * @param integer $id
  * @return string|\yii\web\Response
  */
 public function actionView($id = null)
 {
     $model = User::findOne((int) $id);
     if (empty($model)) {
         $this->error(Yii::t('podium/flash', 'Sorry! We can not find Member with this ID.'));
         return $this->redirect(['admin/members']);
     }
     return $this->render('view', ['model' => $model]);
 }
开发者ID:aekkapun,项目名称:yii2-podium,代码行数:14,代码来源:AdminController.php

示例3: actionForum

 /**
  * Updating the forum details.
  * @return string|\yii\web\Response
  */
 public function actionForum()
 {
     $model = Meta::findOne(['user_id' => Yii::$app->user->id]);
     if (empty($model)) {
         $model = new Meta();
     }
     if ($model->load(Yii::$app->request->post())) {
         $model->user_id = Yii::$app->user->id;
         $uploadAvatar = false;
         $path = Yii::getAlias('@webroot/avatars');
         $avatar = UploadedFile::getInstance($model, 'image');
         if ($avatar) {
             $folderExists = true;
             if (!file_exists($path)) {
                 if (!FileHelper::createDirectory($path)) {
                     $folderExists = false;
                     Log::error('Error while creating avatars folder', null, __METHOD__);
                     $this->error('Sorry! There was an error while creating the avatars folder. Contact administrator about this problem.');
                 }
             }
             if ($folderExists) {
                 if (!empty($model->avatar)) {
                     if (!unlink($path . DIRECTORY_SEPARATOR . $model->avatar)) {
                         Log::error('Error while deleting old avatar image', null, __METHOD__);
                     }
                 }
                 $model->avatar = Yii::$app->security->generateRandomString() . '.' . $avatar->getExtension();
                 $uploadAvatar = true;
             }
         }
         if ($model->save()) {
             if ($uploadAvatar) {
                 if (!$avatar->saveAs($path . DIRECTORY_SEPARATOR . $model->avatar)) {
                     Log::error('Error while saving avatar image', null, __METHOD__);
                     $this->error('Sorry! There was an error while uploading the avatar image. Contact administrator about this problem.');
                 }
             }
             Log::info('Profile updated', !empty($model->id) ? $model->id : '', __METHOD__);
             $this->success('Your profile details have been updated.');
             return $this->refresh();
         } else {
             $model->current_password = null;
         }
     }
     return $this->render('forum', ['model' => $model, 'user' => User::findOne(Yii::$app->user->id)]);
 }
开发者ID:keltstr,项目名称:yii2-podium,代码行数:50,代码来源:ProfileController.php


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