/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $rules = ['cedula' => 'required', 'primer_nombre' => 'required', 'apellido_paterno' => 'required', 'usuario' => 'required', 'password' => ['required', 'confirmed', 'min:6']];
     //Validamos los datos recibidos
     $this->validate($request, $rules);
     $medico = new \App\Medico();
     $medico->fill($request->all());
     //Llena los campos fillable del modelo MEDICO
     $medico->save();
     $user = new \App\User();
     $user->usuario = $request->input('usuario');
     $user->password = bcrypt($request->input('password'));
     $user->rol = 'medico';
     $user->save();
     $profesionalUser = new \App\ProfesionalUsuario();
     $profesionalUser->id_profesional = $medico->id;
     $profesionalUser->id_usuario = $user->id;
     $profesionalUser->save();
     $request->session()->flash('success', 'El medico ' . $request->input('primer_nombre') . ' ' . $request->input('apellido_paterno') . ' se ha registrado correctamente.');
     return redirect()->route('medico.index');
 }