Created
January 1, 2015 02:06
-
-
Save evercode1/1c8bf0fad26c9f101ecc to your computer and use it in GitHub Desktop.
actionCreate 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 actionCreate() | |
| { | |
| $model = new Profile; | |
| $model->user_id = \Yii::$app->user->identity->id; | |
| if ($already_exists = RecordHelpers::userHas('profile')) { | |
| return $this->render('view', [ | |
| 'model' => $this->findModel($already_exists), | |
| ]); | |
| } elseif ($model->load(Yii::$app->request->post()) && $model->save()){ | |
| return $this->redirect(['view']); | |
| } else { | |
| return $this->render('create', [ | |
| 'model' => $model, | |
| ]); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment