/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getDoctorHistory()
 {
     $id = Doctor::doctorLogin();
     $doctor = Doctor::where('id', $id)->first();
     $payments = Userpayment::where('user_id', $doctor->user_id)->where('paid', 1)->get();
     return View::make('clinic.doctor.Payment.History')->with('payments', $payments);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Payment::VeryPayment() == false) {
         return View::make('clinic.payment.renews-payment');
     }
     $id = Doctor::doctorLogin();
     $agenda = Agenda::where('doctor_id', $id)->first();
     $CustomDay = CustomDay::where('agenda_id', $agenda->id)->get();
     return View::make('clinic.doctor.customDay.customDay')->with('customddays', $CustomDay)->with('agendaID', $agenda->id);
 }
 public function getConfigDay()
 {
     if (Payment::VeryPayment() == false) {
         return View::make('clinic.payment.renews-payment');
     }
     $doctor = Doctor::doctorLogin();
     $agenda = Agenda::where('doctor_id', $doctor)->first()->id;
     $configDay = Configday::where('agenda_id', $agenda)->get();
     if ($configDay->isEmpty()) {
         return View::make('clinic.doctor.config.ConfigDay')->with('agenda', $agenda);
     } else {
         return View::make('clinic.doctor.config.ConfigDay')->with('agenda', $agenda)->with('configDay', $configDay);
     }
 }
 public function getConfirmationAppointments()
 {
     $user = Sentry::getUser();
     $pcitas = DB::table('doctors')->join('doctor_patient', 'doctors.id', '=', 'doctor_patient.doctor_id')->join('patients', 'doctor_patient.patient_id', '=', 'patients.id')->join('users', 'patients.user_id', '=', 'users.id')->join('appointments', 'patients.id', '=', 'appointments.patient_id')->where('doctors.id', Doctor::doctorLogin())->groupBy('appointments.id')->get();
     return View::make('clinic.doctor.Appointments.ConfirmationAppointments')->with('citas', $pcitas);
 }
 public function getConfigSave()
 {
     if (Payment::VeryPayment() == false) {
         return View::make('clinic.payment.renews-payment');
     }
     $data = array("insurance" => Input::get("insurance"), "lang" => Input::get("lang"));
     $rules = array("insurance" => 'required|min:1|max:100', "lang" => 'required|min:1|max:100');
     $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');
     $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 = Doctor::doctorLogin();
         $doctor = Doctor::where('id', $id)->first();
         $lang = Option::where('name', $id . '-doctor-lang')->first();
         if ($lang) {
             $lang->key = Input::get("lang");
             $lang->save();
         } else {
             $langadd = new Option();
             $langadd->key = Input::get("lang");
             $langadd->name = $id . '-doctor-lang';
             $langadd->save();
         }
         $opcionSeg = Option::where('name', $id . '-doctor-insurance')->first();
         if ($opcionSeg) {
             $segs = explode(',', Input::get("insurance"));
             $segok = '';
             foreach ($segs as $seg) {
                 $very = Insurance::where('name', 'like', '%' . $seg . '%')->first();
                 if ($very) {
                     $segok = $segok . ',' . $seg;
                 }
             }
             $opcionSeg->key = $segok;
             $opcionSeg->save();
         } else {
             $segs = explode(',', Input::get("insurance"));
             $seguok = '';
             foreach ($segs as $seg) {
                 $very = Insurance::where('name', $seg)->first();
                 if ($very) {
                     $seguok = $seguok . ',' . $seg;
                 }
             }
             $addseg = new Option();
             $addseg->name = $id . '-doctor-insurance';
             $addseg->key = $seguok;
             $addseg->save();
         }
         return Redirect::back();
     }
 }