public function postConfigSave()
 {
     if (Payment::VeryPayment() == false) {
         return View::make('clinic.payment.renews-payment');
     }
     $data = array("name" => Input::get("name"), "insurance" => Input::get("insurance"), "lang" => Input::get("lang"), "picture" => Input::file("picture"), "phone" => Input::get("phone"));
     $rules = array("name" => 'required|min:1|max:255', "insurance" => 'required|min:1|max:255', "lang" => 'required|min:1|max:10', "picture" => 'mimes:jpeg,gif,png', "phone" => 'required|numeric|min:1');
     $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 :attribute debe ser jpg, git, png');
     $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/config-data/')->withErrors($validation)->withInput();
     } else {
         $id = Input::get("id");
         $clinic = Clinic::find($id);
         $clinic->name = Input::get("name");
         $clinic->phone = Input::get("phone");
         $clinic->insurances = Input::get("insurance");
         if (Input::file('picture') != NULL) {
             //agrega imagen de logo
             $file_logo = Input::file('picture');
             $ext = Input::file('picture')->getClientOriginalExtension();
             $nameIMG = date('YmdHis');
             $logo = $nameIMG . '.' . $ext;
             $logo = 'assets/clinic/images/logo/logo_' . $logo;
             $file_logo->move("assets/clinic/images/logo/", $logo);
             $clinic->picture = $logo;
         }
         $clinic->save();
         $adress = Address::find($clinic->address_id);
         $adress->my_address = Input::get("address");
         $adress->save();
         $lang = Option::where('name', $clinic->id . '-clinic-lang')->first();
         if ($lang) {
             $lang->key = Input::get("lang");
             $lang->save();
         } else {
             $langadd = new Option();
             $langadd->key = Input::get("lang");
             $langadd->name = $clinic->id . '-clinic-lang';
             $langadd->save();
         }
         return Redirect::back();
     }
 }
 public function store()
 {
     $data = array("first_name" => Input::get("first_name"), "last_name" => Input::get("last_name"), "email" => Input::get("email"), "username" => Input::get("username"), "phone" => Input::get("phone"), "picture" => Input::file("picture"), "password" => Input::get("password"), "password_confirmation" => Input::get("password_confirmation"));
     $rules = array("first_name" => 'required|min:1|max:255', "last_name" => 'required|min:1|max:100', "email" => 'required|email|unique:users', "username" => 'required|min:5|unique:users', "phone" => 'required|min:1|max:100', "picture" => 'mimes:jpeg,gif,png', 'password' => 'confirmed|min:6');
     $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/doctors/create')->withErrors($validation)->withInput();
     } else {
         $user = new User();
         $user->first_name = Input::get("first_name");
         $user->last_name = Input::get("last_name");
         $user->email = Input::get("email");
         $user->username = Input::get("username");
         $user->password = Input::get("password");
         $user->save();
         $doctorUser = Sentry::getUserProvider()->findByLogin($user->email);
         $doctorsyGroup = Sentry::getGroupProvider()->findByName('Doctors');
         $doctorUser->addGroup($doctorsyGroup);
         $doctor = new Doctor();
         $doctor->user_id = $user->id;
         $doctor->clinic_id = Clinic::getClinicId();
         $doctor->specialty_id = Input::get("specialty_id");
         if (Input::file('picture') != NULL) {
             //agrega imagen de logo
             $file_logo = Input::file('picture');
             $ext = Input::file('picture')->getClientOriginalExtension();
             $nameIMG = date('YmdHis');
             $logo = $nameIMG . '.' . $ext;
             $logo = 'assets/doctor/images/profile_pic/profile_' . $logo;
             $file_logo->move("assets/doctor/images/profile_pic/", $logo);
             $doctor->picture = $logo;
         }
         $doctor->save();
         $clinic = Clinic::find(Clinic::getClinicId());
         $address_id = $clinic->address_id;
         $agenda = new Agenda();
         $agenda->doctor_id = $doctor->id;
         $agenda->name = "Agenda " . Input::get("first_name") . ' ' . Input::get("last_name");
         $agenda->description = 'Nuevo';
         $agenda->save();
         $busines = new Business();
         $busines->doctor_id = $doctor->id;
         $busines->agenda_id = $agenda->id;
         $busines->addresses_id = $address_id;
         $busines->name = 'Local # ';
         $busines->save();
         if (!$logo) {
             $logo = "";
         }
         $profile = new Profile();
         $profile->user_id = $user->id;
         $profile->lang = Input::get("lang");
         $profile->phone = Input::get("phone");
         $profile->picture = $logo;
         $profile->save();
         if ($profile) {
             return Redirect::to('/clinic/doctors/')->withFlash_message("Guardado Exitosamente");
         } else {
             return Redirect::to('/clinic/doctors/create')->withErrors("Error")->withInput();
         }
     }
 }
Example #3
0
 /**
  * Show the form for editing the specified resource.
  * GET /clinics/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $clinic = Clinic::find($id);
     $admin = Employee::where('role', 'Administrator')->where('clinic_id', $clinic->id)->first();
     return View::make('clinics.edit', compact('clinic', 'admin'));
 }