/** * Shows user's profile. * * @param int $id * * @return \yii\web\Response * @throws \yii\web\NotFoundHttpException */ public function actionShow($id) { $profile = $this->finder->findProfileById($id); if ($profile === null) { throw new NotFoundHttpException(); } return $this->render('show', ['profile' => $profile]); }
/** * Shows user's profile. * @param integer $id * @return \yii\web\Response * @throws \yii\web\NotFoundHttpException */ public function actionShow($id) { $profile = $this->finder->findProfileById($id); if ($profile === null) { throw new NotFoundHttpException(); } $fi = FirmaIngeniero::find()->where(['ingeniero_id' => $profile->user_id])->one(); return $this->render('show', ['profile' => $profile, 'fi' => $fi]); }
public function actionIndex() { $id = Yii::$app->user->identity->id; $profile = $this->finder->findProfileById($id); if ($profile === null) { throw new NotFoundHttpException(); } $this->view->params['profile'] = $profile; return $this->render('index'); }
/** * Shows profile settings form. * * @return string|\yii\web\Response */ public function actionProfile() { $model = $this->finder->findProfileById(Yii::$app->user->identity->getId()); $this->performAjaxValidation($model); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->getSession()->setFlash('success', Yii::t('user', 'Your profile has been updated')); return $this->refresh(); } return $this->render('profile', ['model' => $model]); }
/** * Shows user's profile. * * @param int $id * * @return \yii\web\Response * @throws \yii\web\NotFoundHttpException */ public function actionShow($id) { $profile = $this->finder->findProfileById($id); $post = Post::getPostByUser($id); $tags = array(); for ($i = 0; $i < count($post->getModels()); $i++) { array_push($tags, Post_tags::getTags($post->getModels()[$i]['post_id'])); } if ($profile === null) { throw new NotFoundHttpException(); } return $this->render('show', ['profile' => $profile, 'posts' => $post, 'tags' => $tags]); }
/** * Updates an existing User model. * If update is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $user = $this->findModel($id); $user->scenario = 'update'; $profile = $this->finder->findProfileById($id); $r = \Yii::$app->request; $this->performAjaxValidation([$user, $profile]); if ($user->load($r->post()) && $profile->load($r->post()) && $user->save() && $profile->save()) { \Yii::$app->getSession()->setFlash('success', \Yii::t('user', 'User has been updated')); return $this->refresh(); } return $this->render('update', ['user' => $user, 'profile' => $profile, 'module' => $this->module]); }
/** * 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]); }