public function updateCreateProfileForImage($imgPath, $username)
 {
     $UserProfileExists = Profile::find()->where(['user_name' => $username])->count();
     if ($UserProfileExists > 0) {
         $connection = \Yii::$app->db;
         $connection->createCommand()->update('profile', ['profile_picture' => $imgPath], 'user_name ="' . $username . '"')->execute();
     } else {
         $ProfileSocialLogin = new ProfileSocialLogin();
         $ProfileSocialLogin->user_name = $username;
         $ProfileSocialLogin->profile_picture = $imgPath;
         $ProfileSocialLogin->profile_about = 'About Me!';
         $ProfileSocialLogin->insert();
     }
     return true;
 }
Пример #2
0
 protected function setProfileImage($albmsmodel)
 {
     $userModel = '';
     $sqlActivate = '';
     if ($this->_isAgent) {
         $userModel = \frontend\modules\agent\models\Agent::find(['_id' => new \MongoId($albmsmodel->profile_id)]);
     } else {
         $userModel = \frontend\modules\profile\models\Profile::find(['_id' => new \MongoId($albmsmodel->profile_id)]);
     }
     if (empty($userModel->profile_image)) {
         $userModel->profile_image = $this->_defaultImage;
         $userModel->save(false);
         $albmsmodel->profile_image = 1;
         $albmsmodel->save();
     }
 }