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


PHP Profile::findOne方法代码示例

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


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

示例1: actionView

 public function actionView($title)
 {
     $eventId = explode('-', $title)[1];
     //$training = Events::find(['id' => $eventId[1]])->one();
     $training = $this->findModel($eventId);
     return $this->render('training', ['training' => $training, 'organizer' => Profile::findOne(['user_id' => $training['organizer_id']]), 'eventsList' => Events::find()->limit('4')->all()]);
 }
开发者ID:Akelcehg,项目名称:psycho,代码行数:7,代码来源:TrainingsController.php

示例2: updateProfile

 public function updateProfile()
 {
     $profile = ($profile = Profile::findOne(Yii::$app->user->id)) ? $profile : new Profile();
     $profile->user_id = Yii::$app->user->id;
     $profile->first_name = $this->first_name;
     $profile->last_name = $this->last_name;
     return $profile->save() ? true : false;
 }
开发者ID:sAnbl4,项目名称:yii2test,代码行数:8,代码来源:Profile.php

示例3: findModel

 protected function findModel($id)
 {
     if (($model = Profile::findOne(['user_id' => $id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:Akelcehg,项目名称:psycho,代码行数:8,代码来源:Module.php

示例4: getUsername

 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUsername()
 {
     if (!Yii::$app->user->isGuest) {
         $user = Yii::$app->user->getIdentity();
         $id = $user->id;
         $user_id = Profile::findOne(['user_id' => $id]);
         return $user_id->second_name . " " . $user_id->first_name;
     }
 }
开发者ID:Ramengel,项目名称:yii_fl,代码行数:12,代码来源:Topic.php

示例5: findModel

 protected function findModel()
 {
     if ($model = Profile::findOne(Yii::$app->user->identity->getId())) {
         $model->username = $model->user->username;
         $model->email = $model->user->email;
         $model->role = $model->user->role;
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:fosker,项目名称:sim,代码行数:11,代码来源:ProfileController.php

示例6: actionApprove

 public function actionApprove($id)
 {
     $model = $this->findModel($id);
     $model->is_approved = 1;
     if ($profile = Profile::findOne(['user_id' => $model['psychologist_id']])) {
         $profile->has_diplom = 1;
         $profile->save();
     }
     if ($model->save()) {
         return $this->redirect(['index']);
     }
 }
开发者ID:Akelcehg,项目名称:psycho,代码行数:12,代码来源:DiplomasController.php

示例7: actionProfile

 /**
  * Profile
  */
 public function actionProfile()
 {
     /** @var User $user */
     /** @var Profile $profile */
     // get user and profile
     $user = $this->jwtAuth->getAuthenticatedUser();
     $profile = Profile::findOne(["user_id" => $user->id]);
     // update profile
     if ($profile->loadPostAndSave() === false) {
         return ["errors" => $profile->errors];
     }
     return ["success" => ["profile" => $profile]];
 }
开发者ID:amnah,项目名称:yii2-angular,代码行数:16,代码来源:UserController.php

示例8: actionProfile

 public function actionProfile()
 {
     $model = ($model = Profile::findOne(Yii::$app->user->id)) ? $model : new Profile();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->updateProfile()) {
             Yii::$app->session->setFlash('success', 'Профиль изменен');
         } else {
             Yii::$app->session->setFlash('error', 'Профиль не изменен');
             Yii::error('Ошибка записи. Профиль не изменен');
             return $this->refresh();
         }
     }
     return $this->render('profile', ['model' => $model]);
 }
开发者ID:jiddihub,项目名称:our-yii-app,代码行数:14,代码来源:MainController.php

示例9: updateProfile

 public function updateProfile($profile)
 {
     $profile = ($profile = Profile::findOne(Yii::$app->user->id)) ? $profile : new Profile();
     $profile->user_id = Yii::$app->user->id;
     $profile->nickname = $this->nickname;
     /* a lil bit check whether the file uploaded well for both avatar and background */
     if ($this->file) {
         $profile->avatar = $this->file->getBaseName() . '.' . $this->file->getExtension();
     }
     if (isset($this->background_file)) {
         $profile->background_img = $this->background_file->getBaseName() . '.' . $this->background_file->getExtension();
     }
     return $profile->save() ? $profile : null;
 }
开发者ID:phstoned,项目名称:blog-boostrap,代码行数:14,代码来源:Profile.php

示例10: actionView

 public function actionView($title)
 {
     $articleId = explode('-', $title);
     $articleModel = new ArticleComments();
     $model = new ArticleComments();
     $model->user_id = Yii::$app->user->id;
     $article = $this->findModel($articleId[1]);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->render('view', ['model' => $article, 'articleComments' => $articleModel, 'articleCommentsList' => ArticleComments::getArticleComments($articleId[1]), 'popularPosts' => Article::getPopularPosts(), 'author' => Profile::findOne(['user_id' => $article['psychologist_id']])]);
     }
     if ($articleId[1]) {
         $articleModel->article_id = $articleId[1];
         return $this->render('view', ['model' => $article, 'articleComments' => $articleModel, 'articleCommentsList' => ArticleComments::getArticleComments($articleId[1]), 'popularPosts' => Article::getPopularPosts(), 'author' => Profile::findOne(['user_id' => $article['psychologist_id']])]);
     }
 }
开发者ID:Akelcehg,项目名称:psycho,代码行数:15,代码来源:ArticleController.php

示例11: updateProfile

 public function updateProfile()
 {
     $profile = ($profile = Profile::findOne(Yii::$app->user->id)) ? $profile : new Profile();
     $profile->user_id = Yii::$app->user->id;
     $profile->first_name = $this->first_name;
     $profile->second_name = $this->second_name;
     $profile->middle_name = $this->middle_name;
     if ($profile->save()) {
         $user = $this->user ? $this->user : User::findOne(Yii::$app->user->id);
         $username = Yii::$app->request->post('User')['username'];
         $user->username = isset($username) ? $username : $user->username;
         return $user->save() ? true : false;
     }
     return false;
 }
开发者ID:AndMak15,项目名称:our-yii-app,代码行数:15,代码来源:Profile.php

示例12: updateProfile

 /**
  * Обновление профиля
  * @return bool
  */
 public function updateProfile()
 {
     $profile = ($profile = Profile::findOne(Yii::$app->user->id)) ? $profile : new Profile();
     $profile->user_id = Yii::$app->user->id;
     $profile->first_name = $this->first_name;
     $profile->second_name = $this->second_name;
     $profile->middle_name = $this->middle_name;
     // Сохранение логина
     if ($profile->save()) {
         $user = $this->user ? $this->user : User::findOne(Yii::$app->user->id);
         $login = Yii::$app->request->post('User')['login'];
         $user->login = isset($login) ? $login : $user->login;
         return (bool) $user->save();
         // var_dump($user->getErrors());
     }
     return false;
 }
开发者ID:va-fursenko,项目名称:yii.dev,代码行数:21,代码来源:Profile.php

示例13: updateProfile

 public function updateProfile()
 {
     $profile = ($profile = Profile::findOne(Yii::$app->user->id)) ? $profile : new Profile();
     $profile->user_id = Yii::$app->user->id;
     $profile->first_name = $this->first_name;
     $profile->second_name = $this->second_name;
     $profile->middle_name = $this->middle_name;
     $profile->profile_status = $this->profile_status;
     $profile->birthday = $this->birthday;
     $profile->gender = $this->gender;
     $user_avatar = UploadedFile::getInstance($this, 'avatar_file');
     if ($user_avatar) {
         $profile->avatar = 'images/avatars/' . $user_avatar->baseName . '.' . $user_avatar->extension;
         $user_avatar->saveAs('images/avatars/' . $user_avatar->baseName . '.' . $user_avatar->extension);
     }
     return $profile->save() ? true : false;
 }
开发者ID:Ramengel,项目名称:yii_fl,代码行数:17,代码来源:Profile.php

示例14: actionViewProfile

 public function actionViewProfile($id)
 {
     if (!Yii::$app->user->isGuest) {
         if ($id == Yii::$app->user->id or Yii::$app->user->can('user')) {
             $model = Profile::findOne($id);
             if (!empty($model)) {
                 return $this->render('viewProfile', ['model' => $model]);
             } else {
                 $model = new Profile();
                 Yii::$app->session->setFlash('success', "Профиль не заполнен. Заполните пожалустай.");
                 return $this->render('update-profile', ['model' => $model]);
             }
         } else {
             Yii::$app->session->setFlash('error', 'Нет доступа!');
             $this->redirect('/');
         }
     } else {
         Yii::$app->session->setFlash('error', 'Нет доступа!');
         $this->redirect('/');
     }
 }
开发者ID:dosh93,项目名称:shop,代码行数:21,代码来源:UserController.php

示例15: createMenu

 public function createMenu()
 {
     $menu = "";
     if (!Yii::$app->user->isGuest) {
         $profile = Profile::findOne(Yii::$app->user->identity->profile_id);
         $menu .= "<h2><span class='label label-primary'>{$profile->name}</span></h2>";
         //            $menu .= "<a href='" . Url::toRoute("site/index") . "'><i class='fa fa-fw fa-home'></i><span>Home</span></a>";
         $access = Access::find()->where(["profile_id" => Yii::$app->user->identity->profile_id])->all();
         foreach ($access as $value) {
             $module = Module::find()->where(["id" => $value->module_id])->one();
             $path = "{$module->controller}/index";
             $href = Url::toRoute($path);
             $link = "<a href='{$href}'><i class='fa fa-fw {$module->iconfa}'></i><span>{$module->label}</span></a>";
             $menu .= $link;
         }
     }
     //        if (Yii::$app->user->isGuest) {
     //            $menu .= "<a href='" . Url::toRoute('site/login') . "'><i class='fa fa-fw fa-sign-in'></i><span>Login</span></a>";
     //        } else {
     //            $menu .= "<a href='" . Url::toRoute('site/logout') . "' data-method='post'><i class='fa fa-fw fa-sign-out'></i><span>Logout (" . Yii::$app->user->identity->username . ")</span></a>";
     //        }
     return $menu;
 }
开发者ID:alfredosotil,项目名称:swinnapp,代码行数:23,代码来源:AppAsset.php


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