/** * Creates a new Blood model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($pid) { $model = Blood::findOne(['fk_person' => $pid]); if (empty($model)) { $model = new Blood(); $model->fk_person = $pid; $model->creation_name = Yii::$app->user->identity->username; $model->creation_time = date("Y-m-d H:i:s"); $model->altered = 1; if ($model->save(FALSE)) { return $this->refresh(); } } else { return $this->redirect(["blood/update/{$model->id}"]); } }