Exemplo n.º 1
0
 public function putCambiarimgunalumno($alumnoElegido)
 {
     $alumno = Alumno::findOrFail($alumnoElegido);
     $alumno->foto_id = Request::input('imgOficialAlumno');
     $alumno->save();
     return $alumno;
 }
Exemplo n.º 2
0
 public function putUpdate($id)
 {
     $alumno = Alumno::findOrFail($id);
     $this->sanarInputAlumno();
     try {
         $alumno->no_matricula = Request::input('no_matricula');
         $alumno->nombres = Request::input('nombres');
         $alumno->apellidos = Request::input('apellidos');
         $alumno->sexo = Request::input('sexo', 'M');
         $alumno->fecha_nac = Request::input('fecha_nac');
         $alumno->ciudad_nac = Request::input('ciudad_nac')['id'];
         $alumno->tipo_doc = Request::input('tipo_doc')['id'];
         $alumno->documento = Request::input('documento');
         $alumno->ciudad_doc = Request::input('ciudad_doc')['id'];
         $alumno->tipo_sangre = Request::input('tipo_sangre')['sangre'];
         $alumno->eps = Request::input('eps');
         $alumno->telefono = Request::input('telefono');
         $alumno->celular = Request::input('celular');
         $alumno->barrio = Request::input('barrio');
         $alumno->estrato = Request::input('estrato');
         $alumno->ciudad_resid = Request::input('ciudad_resid');
         $alumno->religion = Request::input('religion');
         $alumno->email = Request::input('email');
         $alumno->facebook = Request::input('facebook');
         $alumno->foto_id = Request::input('foto_id');
         $alumno->pazysalvo = Request::input('pazysalvo', true);
         $alumno->deuda = Request::input('deuda');
         if ($alumno->user_id and Request::has('username')) {
             $this->sanarInputUser();
             $this->checkOrChangeUsername($alumno->user_id);
             $usuario = User::find($alumno->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::has('password')) {
                 if (Request::input('password') == "") {
                     $usuario->password = Hash::make(Request::input('password'));
                 }
             }
             $usuario->save();
             $alumno->user_id = $usuario->id;
             $alumno->save();
             $alumno->user = $usuario;
         }
         if (!$alumno->user_id and Request::has('username')) {
             $this->sanarInputUser();
             $this->checkOrChangeUsername($alumno->user_id);
             $yearactual = Year::actual();
             $periodo_actual = Periodo::where('actual', true)->where('year_id', $yearactual->id)->first();
             $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->periodo_id = $periodo_actual->id;
             $usuario->save();
             $alumno->user_id = $usuario->id;
             $alumno->save();
             $alumno->user = $usuario;
         }
         if (Request::input('grupo')['id']) {
             $grupo_id = Request::input('grupo')['id'];
             $matricula = Matricula::matricularUno($alumno->id, $grupo_id);
             $grupo = Grupo::find($matricula->grupo_id);
             $alumno->grupo = $grupo;
         }
         return $alumno;
     } catch (Exception $e) {
         return abort('400', $e);
     }
 }