public function index(Request $request, $slug, $date)
 {
     // Gets the query string from our form submission
     $query = $request->rfc;
     $intervaloPrimeravez = '["00:00", "00:00"]';
     // Returns an array of articles that have the query string located somewhere within
     // our articles titles. Paginates them so we can break up lots of search results.
     $pacientes = Paciente::where('rfc', '=', $query)->get();
     $pacientes->each(function ($pacientes) {
         $pacientes->tipo;
     });
     $medico = Medico::findBySlug($slug);
     $medico->especialidad;
     $medico->horario;
     $minutes = $medico->minutes ? $medico->minutes : 20;
     $timeminutes = '+' . $minutes * 4 . ' minutes';
     if (!\Auth::user()->admin()) {
         $intervaloPrimeravez = '["' . $medico->horario->entrada . '","' . date('H:i', strtotime($timeminutes, strtotime($medico->horario->entrada))) . '"]';
     }
     $todas_citas = Cita::getTotalCitas($medico->id, $date);
     $horas_usadas = Cita::where('fecha', '=', $date)->where('medico_id', '=', $medico->id)->lists('horario', 'id')->toArray();
     $horas = array();
     foreach ($horas_usadas as $hora) {
         $horas[] = '["' . Carbon::createFromFormat('H:i', $hora)->toTimeString() . '","' . Carbon::createFromFormat('H:i', $hora)->addMinutes($minutes)->toTimeString() . '"]';
     }
     $horas = implode(",", $horas);
     $entrada = $medico->horario->entrada;
     $salida = $medico->horario->salida;
     // returns a view and passes the view the list of articles and the original query.
     return view('admin.citas.create')->with('pacientes', $pacientes)->with('medico', $medico)->with('date', $date)->with('todas_citas', $todas_citas)->with('horas', $horas)->with('entrada', $entrada)->with('salida', $salida)->with('intervaloPrimeravez', $intervaloPrimeravez)->with('minutes', $minutes);
 }
Пример #2
0
 public function concretada($slug, $date, $id)
 {
     $cita = Cita::find($id);
     if ($cita->concretada == 1) {
         $cita->concretada = 0;
     } else {
         $cita->concretada = 1;
     }
     $cita->save();
     $medico = Medico::findBySlug($slug);
     $medico->especialidad;
     Toastr::success('Cita Concretada');
     return redirect()->route('admin.citas.show', ['slug' => $slug, 'date' => $date]);
 }