/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Pacientes(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Pacientes'])) { $model->attributes = $_POST['Pacientes']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->IdPaciente)); } } $this->render('create', array('model' => $model)); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $validator = Validator::make(Input::all(), Pacientes::$p_rules); if ($validator->passes()) { if (Input::get('fecha_nac')) { $fecha_nac = explode('/', Input::get('fecha_nac')); $fecha_nac = $fecha_nac[2] . "-" . $fecha_nac[1] . "-" . $fecha_nac[0]; $nuevo_paciente->fechanacimiento = $fecha_nac; } $nuevo_paciente = new Pacientes(Input::all()); $nuevo_paciente->saldo = 0; $nuevo_paciente->save(); return Redirect::action('PacientesController@index')->with('message', 'Paciente creado con éxito.'); } else { return Redirect::action('PacientesController@create')->with('message', 'Existen los siguientes errores:')->withErrors($validator)->withInput(); } }