public function actionMydesignerprofilepage() { $model = new Profile(); $designerModel = new DesignerSocialLogin(); $session = new Session(); $session->open(); //$session['user_name'] = 'DummyDesigner1'; //Fetch profile information from DB $prof_info = $model->getProfileInfo($session['user_name']); $imgPath = $prof_info->profile_picture; $name = (new DesignerSocialLogin())->getDesignerInfo($session['user_name']); $endorsement = (new Endorsement())->getUserEndorsementData($session['user_name']); //Update profile image and if not already created, create customer profile if ($model->load(Yii::$app->request->post()) && $model->validate()) { $model->imageFile = UploadedFile::getInstance($model, 'imageFile'); if (isset($model->imageFile->extension)) { $imgPath = 'uploads/profilepictures/' . $session['user_name'] . '_profimg.' . $model->imageFile->extension; $model->imageFile->saveAs($imgPath); $UserProfileExists = (new Profile())->updateCreateProfileForImage($imgPath, $session['user_name']); } } return $this->render('mydesignerprofile', ['model' => $model, 'about' => $prof_info->profile_about, 'imgPath' => $imgPath, 'name' => $name, 'prof_info' => $prof_info, 'endorsement' => $endorsement, 'designerModel' => $designerModel]); }
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; }
$todisplay1 = 'false'; $todisplay2 = 'false'; $todisplay3 = 'false'; if ($i < sizeof($myfriends)) { $todisplay1 = 'true'; $imgpath1 = Profile::findBySql('select profile_picture from profile where user_name ="' . $myfriends[$i]->customer_user_name2 . '"')->one(); $name1 = CustomerSocialLogin::findBySql('select customer_first_name, customer_last_name from customer where customer_user_name ="' . $myfriends[$i]->customer_user_name2 . '"')->one(); } if ($i + 1 < sizeof($myfriends)) { $todisplay2 = 'true'; $imgpath2 = Profile::findBySql('select profile_picture from profile where user_name ="' . $myfriends[$i + 1]->customer_user_name2 . '"')->one(); $name2 = CustomerSocialLogin::findBySql('select customer_first_name, customer_last_name from customer where customer_user_name ="' . $myfriends[$i + 1]->customer_user_name2 . '"')->one(); } if ($i + 2 < sizeof($myfriends)) { $todisplay3 = 'true'; $imgpath3 = Profile::findBySql('select profile_picture from profile where user_name ="' . $myfriends[$i + 2]->customer_user_name2 . '"')->one(); $name3 = CustomerSocialLogin::findBySql('select customer_first_name, customer_last_name from customer where customer_user_name ="' . $myfriends[$i + 2]->customer_user_name2 . '"')->one(); } ?> <div class="row row-list" id="friendlist"> <?php if ($todisplay1 == 'true') { ?> <div class="col-xs-3"> <?php echo Html::img($imgpath1->profile_picture, ['width' => 100, 'height' => 100]); echo "<br/>"; ?> <a href="index.php?r=profile/default/viewprofile&username=<?php echo $myfriends[$i]->customer_user_name2;
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(); } }
/** * @return \yii\db\ActiveQuery */ public function getProfile() { return $this->hasOne(Profile::className(), ['customer_user_name' => 'customer_user_name']); }