當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。