예제 #1
0
 public function putUpdate($id)
 {
     $this->sanarInputUser();
     $this->sanarInputProfesor();
     $profesor = Profesor::findOrFail($id);
     try {
         $profesor->nombres = Request::input('nombres_profesor', Request::input('nombres'));
         $profesor->apellidos = Request::input('apellidos_profesor', Request::input('apellidos'));
         $profesor->sexo = Request::input('sexo');
         $profesor->tipo_doc = Request::input('tipo_doc');
         $profesor->num_doc = Request::input('num_doc');
         $profesor->ciudad_doc = Request::input('ciudad_doc');
         $profesor->fecha_nac = Request::input('fecha_nac');
         $profesor->ciudad_nac = Request::input('ciudad_nac');
         $profesor->titulo = Request::input('titulo');
         $profesor->estado_civil = Request::input('estado_civil');
         $profesor->barrio = Request::input('barrio');
         $profesor->direccion = Request::input('direccion');
         $profesor->telefono = Request::input('telefono');
         $profesor->celular = Request::input('celular');
         $profesor->facebook = Request::input('facebook');
         $profesor->email = Request::input('email');
         //$profesor->tipo_profesor	=>	Request::input('tipo_profesor')
         $profesor->save();
         if ($profesor->user_id and Request::input('username')) {
             $this->sanarInputUser();
             $this->checkOrChangeUsername($profesor->user_id);
             $usuario = User::find($profesor->user_id);
             $usuario->username = Request::input('username');
             $usuario->email = Request::input('email2');
             $usuario->is_superuser = Request::input('is_superuser', false);
             $usuario->is_active = Request::input('is_active', true);
             if (Request::input('password')) {
                 if (Request::input('password') != "") {
                     $usuario->password = Hash::make(Request::input('password'));
                 }
             }
             $usuario->save();
             $profesor->user_id = $usuario->id;
             $profesor->save();
             $profesor->user = $usuario;
         } else {
             if (!$profesor->user_id and Request::input('username')) {
                 $this->sanarInputUser();
                 $this->checkOrChangeUsername($profesor->user_id);
                 $usuario = new User();
                 $usuario->username = Request::input('username');
                 $usuario->password = Hash::make(Request::input('password', '123456'));
                 $usuario->email = Request::input('email2');
                 $usuario->is_superuser = Request::input('is_superuser', false);
                 $usuario->is_active = Request::input('is_active', true);
                 $usuario->save();
                 $profesor->user_id = $usuario->id;
                 $profesor->save();
                 $profesor->user = $usuario;
             }
         }
         return $profesor;
     } catch (Exception $e) {
         return abort(400, $e);
     }
 }
예제 #2
0
 public function putCambiarfirmaunprofe($profeElegido)
 {
     $profesor = Profesor::findOrFail($profeElegido);
     $profesor->firma_id = Request::input('imgFirmaProfe');
     $profesor->save();
     return $profesor;
 }