/** * Creates a new Urine model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($pid) { $model = Urine::findOne(['fk_person' => $pid]); if (empty($model)) { $model = new Urine(); $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; $model->save(FALSE); } return $this->redirect(["urine/update/{$model->id}"]); }