/** * Creates a new Administrador model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Administrador(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Persona model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Persona(); $modelAdmin = new Administrador(); $modelProfesional = new Profesional(); $modelPaciente = new Paciente(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->perfil == 1) { $model->save(false); $modelAdmin->persona_id = $model->id; $modelAdmin->save(false); if ($model->save(false)) { return $this->redirect(['view', 'id' => $model->id]); } } else { if ($model->perfil == 2) { $model->save(false); $modelProfesional->persona_id = $model->id; $modelProfesional->save(false); if ($model->save(false)) { return $this->redirect(['view', 'id' => $model->id]); } } else { if ($model->perfil == 3) { $model->save(false); $modelPaciente->persona_id = $model->id; $modelPaciente->descripcion = $model->descripcion; $modelPaciente->save(false); if ($model->save(false)) { return $this->redirect(['view', 'id' => $model->id]); } } } } } else { return $this->render('create', ['model' => $model]); } }