public function loadAttributes(User $user) { $user->setAttributes($this->attributes); $profile = \Yii::createObject(Profile::className()); $profile->setAttributes(['name' => $this->name]); $user->setProfile($profile); }
/** @inheritdoc */ public function afterSave($insert, $changedAttributes) { if ($insert) { $profile = \Yii::createObject(['class' => Profile::className(), 'user_id' => $this->id, 'gravatar_email' => $this->email]); $profile->save(false); } parent::afterSave($insert, $changedAttributes); }
/** * Shows profile settings form. * * @return string|\yii\web\Response */ public function actionProfile() { $model = $this->finder->findProfileById(Yii::$app->user->identity->getId()); if ($model == null) { $model = Yii::createObject(Profile::className()); $model->link('user', Yii::$app->user->identity); } $event = $this->getProfileEvent($model); $this->performAjaxValidation($model); $this->trigger(self::EVENT_BEFORE_PROFILE_UPDATE, $event); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->getSession()->setFlash('success', Yii::t('user', 'Your profile has been updated')); $this->trigger(self::EVENT_AFTER_PROFILE_UPDATE, $event); return $this->refresh(); } return $this->render('profile', ['model' => $model]); }
/** @inheritdoc */ public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if ($insert) { if ($this->_profile == null) { $this->_profile = Yii::createObject(Profile::className()); } $this->_profile->link('user', $this); } }
/** * Updates an existing profile. * * @param int $id * * @return mixed */ public function actionUpdateProfile($id) { Url::remember('', 'actions-redirect'); $user = $this->findModel($id); $profile = $user->profile; $event = $this->getProfileEvent($profile); if ($profile == null) { $profile = Yii::createObject(Profile::className()); $profile->link('user', $user); } $this->performAjaxValidation($profile); $this->trigger(self::EVENT_BEFORE_PROFILE_UPDATE, $event); if ($profile->load(Yii::$app->request->post()) && $profile->save()) { Yii::$app->getSession()->setFlash('success', Yii::t('user', 'Profile details have been updated')); $this->trigger(self::EVENT_AFTER_PROFILE_UPDATE, $event); return $this->refresh(); } return $this->render('_profile', ['user' => $user, 'profile' => $profile]); }
public function getKursTeacher() { return $this->hasOne(Profile::className(), ['user_id' => 'user_id']); }
public function getStaff() { return $this->hasOne(Profile::className(), ['user_id' => 'mod']); }
/** * @return \yii\db\ActiveQuery */ public function getProfile() { return $this->hasOne(\dektrium\user\models\Profile::className(), ['user_id' => 'id']); }