Created
January 1, 2015 02:13
-
-
Save evercode1/e1f2abeb6dac685bdd00 to your computer and use it in GitHub Desktop.
actionUpdate Profile Controller Chap 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function actionUpdate() | |
| { | |
| if($model = Profile::find()->where(['user_id' => Yii::$app->user->identity->id])->one()) { | |
| if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
| return $this->redirect(['view']); | |
| } else { | |
| return $this->render('update', [ | |
| 'model' => $model, | |
| ]); | |
| } | |
| } else { | |
| throw new NotFoundHttpException('No Such Profile.'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if($model = Profile::find()->where(['user_id' => Yii::$app->user->identity->id])->one()) { ... }
why use tenary operator for $model because $model does not have value yet.