Skip to content

Instantly share code, notes, and snippets.

@evercode1
Created January 1, 2015 02:06
Show Gist options
  • Select an option

  • Save evercode1/1c8bf0fad26c9f101ecc to your computer and use it in GitHub Desktop.

Select an option

Save evercode1/1c8bf0fad26c9f101ecc to your computer and use it in GitHub Desktop.
actionCreate Profile Controller Chap 8
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