public function update($id) { $data = array("day" => Input::get("day"), "starttime_am" => Input::get("starttime_am"), "endttime_am" => Input::get("endtime_am"), "lunch_start" => Input::get("lunch_startlunch_start"), "lunch_end" => Input::get("lunch_startlunch_end"), "starttime_pm" => Input::get("starttime_pm"), "endtime_pm" => Input::get("endtime_pm"), "is_day_off" => Input::get("is_day_off")); $rules = array("day" => 'required|min:1|max:255'); $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'numeric' => 'El campo :attribute debe contener solo numeros', 'mimes' => 'El formato de la imagen logo debe ser jpg, git, png', 'unique' => 'El :attribute ingresado ya esta siendo usaddo por otro usuario.', 'confirmed' => 'La confirmación del :attribute no coincide'); $validation = Validator::make(Input::all(), $rules, $messages); //si la validación falla redirigimos al formulario de registro con los errores //y con los campos que nos habia llenado el usuario if ($validation->fails()) { return Redirect::to('/clinic/doctor/custom-days/' . $id . '/edit')->withErrors($validation)->withInput(); } else { $customDay = CustomDay::find($id); $customDay->agenda_id = Input::get("agenda_id"); $customDay->day = Input::get("day"); $customDay->starttime_am = CustomDay::eliminarespacios(Input::get("starttime_am")); $customDay->endtime_am = CustomDay::eliminarespacios(Input::get("endtime_am")); $customDay->lunch_start = CustomDay::eliminarespacios(Input::get("lunch_start")); $customDay->lunch_end = CustomDay::eliminarespacios(Input::get("lunch_end")); $customDay->starttime_pm = CustomDay::eliminarespacios(Input::get("starttime_pm")); $customDay->endtime_pm = CustomDay::eliminarespacios(Input::get("endtime_pm")); $customDay->is_day_off = Input::get("is_day_off"); $customDay->save(); if ($customDay) { return Redirect::to('/clinic/doctor/custom-days/' . Input::get("agenda_id"))->withFlash_message("Guardado Exitosamente"); } else { return Redirect::to('/clinic/doctor/custom-days/' . $id . '/edit')->withErrors("Error")->withInput(); } } }
public function postConfigDaySave() { /*-------------------Domingo-----------------------------*/ $configDay = Configday::where('day', 'Sunday')->where('agenda_id', Input::get("agenda"))->first(); if (!$configDay) { $configDay = new Configday(); } $configDay->agenda_id = Input::get("agenda"); $configDay->day = 'Sunday'; $configDay->starttime_am = CustomDay::eliminarespacios(Input::get("starttime_am")); $configDay->endtime_am = CustomDay::eliminarespacios(Input::get("endtime_am")); $configDay->lunch_start = CustomDay::eliminarespacios(Input::get("lunch_start")); $configDay->lunch_end = CustomDay::eliminarespacios(Input::get("lunch_end")); $configDay->starttime_pm = CustomDay::eliminarespacios(Input::get("starttime_pm")); $configDay->endtime_pm = CustomDay::eliminarespacios(Input::get("endtime_pm")); $configDay->is_day_off = Input::get("is_day_off"); $configDay->save(); /*-------------------Lunes-----------------------------*/ $configDay1 = Configday::where('day', 'Monday')->where('agenda_id', Input::get("agenda"))->first(); if (!$configDay1) { $configDay1 = new Configday(); } $configDay1->agenda_id = Input::get("agenda"); $configDay1->day = 'Monday'; $configDay1->starttime_am = CustomDay::eliminarespacios(Input::get("starttime_am_1")); $configDay1->endtime_am = CustomDay::eliminarespacios(Input::get("endtime_am_1")); $configDay1->lunch_start = CustomDay::eliminarespacios(Input::get("lunch_start_1")); $configDay1->lunch_end = CustomDay::eliminarespacios(Input::get("lunch_end_1")); $configDay1->starttime_pm = CustomDay::eliminarespacios(Input::get("starttime_pm_1")); $configDay1->endtime_pm = CustomDay::eliminarespacios(Input::get("endtime_pm_1")); $configDay1->is_day_off = Input::get("is_day_off_1"); $configDay1->save(); /*-------------------Martes-----------------------------*/ $configDay2 = Configday::where('day', 'Tuesday')->where('agenda_id', Input::get("agenda"))->first(); if (!$configDay2) { $configDay2 = new Configday(); } $configDay2->agenda_id = Input::get("agenda"); $configDay2->day = 'Tuesday'; $configDay2->starttime_am = CustomDay::eliminarespacios(Input::get("starttime_am_2")); $configDay2->endtime_am = CustomDay::eliminarespacios(Input::get("endtime_am_2")); $configDay2->lunch_start = CustomDay::eliminarespacios(Input::get("lunch_start_2")); $configDay2->lunch_end = CustomDay::eliminarespacios(Input::get("lunch_end_2")); $configDay2->starttime_pm = CustomDay::eliminarespacios(Input::get("starttime_pm_2")); $configDay2->endtime_pm = CustomDay::eliminarespacios(Input::get("endtime_pm_2")); $configDay2->is_day_off = Input::get("is_day_off_2"); $configDay2->save(); /*-------------------Miercoles-----------------------------*/ $configDay3 = Configday::where('day', 'Wednesday')->where('agenda_id', Input::get("agenda"))->first(); if (!$configDay3) { $configDay3 = new Configday(); } $configDay3->agenda_id = Input::get("agenda"); $configDay3->day = 'Wednesday'; $configDay3->starttime_am = CustomDay::eliminarespacios(Input::get("starttime_am_3")); $configDay3->endtime_am = CustomDay::eliminarespacios(Input::get("endtime_am_3")); $configDay3->lunch_start = CustomDay::eliminarespacios(Input::get("lunch_start_3")); $configDay3->lunch_end = CustomDay::eliminarespacios(Input::get("lunch_end_3")); $configDay3->starttime_pm = CustomDay::eliminarespacios(Input::get("starttime_pm_3")); $configDay3->endtime_pm = CustomDay::eliminarespacios(Input::get("endtime_pm_3")); $configDay3->is_day_off = Input::get("is_day_off_3"); $configDay3->save(); /*-------------------Jueves-----------------------------*/ $configDay4 = Configday::where('day', 'Thursday')->where('agenda_id', Input::get("agenda"))->first(); if (!$configDay4) { $configDay4 = new Configday(); } $configDay4->agenda_id = Input::get("agenda"); $configDay4->day = 'Thursday'; $configDay4->starttime_am = CustomDay::eliminarespacios(Input::get("starttime_am_4")); $configDay4->endtime_am = CustomDay::eliminarespacios(Input::get("endtime_am_4")); $configDay4->lunch_start = CustomDay::eliminarespacios(Input::get("lunch_start_4")); $configDay4->lunch_end = CustomDay::eliminarespacios(Input::get("lunch_end_4")); $configDay4->starttime_pm = CustomDay::eliminarespacios(Input::get("starttime_pm_4")); $configDay4->endtime_pm = CustomDay::eliminarespacios(Input::get("endtime_pm_4")); $configDay4->is_day_off = Input::get("is_day_off_4"); $configDay4->save(); /*-------------------Viernes-----------------------------*/ $configDay5 = Configday::where('day', 'Friday')->where('agenda_id', Input::get("agenda"))->first(); if (!$configDay5) { $configDay5 = new Configday(); } $configDay5->agenda_id = Input::get("agenda"); $configDay5->day = 'Friday'; $configDay5->starttime_am = CustomDay::eliminarespacios(Input::get("starttime_am_5")); $configDay5->endtime_am = CustomDay::eliminarespacios(Input::get("endtime_am_5")); $configDay5->lunch_start = CustomDay::eliminarespacios(Input::get("lunch_start_5")); $configDay5->lunch_end = CustomDay::eliminarespacios(Input::get("lunch_end_5")); $configDay5->starttime_pm = CustomDay::eliminarespacios(Input::get("starttime_pm_5")); $configDay5->endtime_pm = CustomDay::eliminarespacios(Input::get("endtime_pm_5")); $configDay5->is_day_off = Input::get("is_day_off_5"); $configDay5->save(); /*-------------------Sabado-----------------------------*/ $configDay6 = Configday::where('day', 'Saturday')->where('agenda_id', Input::get("agenda"))->first(); if (!$configDay6) { $configDay6 = new Configday(); } $configDay6->agenda_id = Input::get("agenda"); $configDay6->day = 'Saturday'; $configDay6->starttime_am = CustomDay::eliminarespacios(Input::get("starttime_am_6")); $configDay6->endtime_am = CustomDay::eliminarespacios(Input::get("endtime_am_6")); $configDay6->lunch_start = CustomDay::eliminarespacios(Input::get("lunch_start_6")); $configDay6->lunch_end = CustomDay::eliminarespacios(Input::get("lunch_end_6")); $configDay6->starttime_pm = CustomDay::eliminarespacios(Input::get("starttime_pm_6")); $configDay6->endtime_pm = CustomDay::eliminarespacios(Input::get("endtime_pm_6")); $configDay6->is_day_off = Input::get("is_day_off_6"); $configDay6->save(); return Redirect::back(); }