Пример #1
0
 public function editarDatos()
 {
     if (Request::ajax()) {
         $new_profesor = Profesor::find(Auth::user()->id);
         $new_profesor->email = Input::get("email");
         $new_datos_profesor = DatosProfesor::where('profesor_id', '=', Auth::user()->id)->first();
         $new_datos_profesor->nombre = Input::get("nombre");
         $new_datos_profesor->apellido_paterno = Input::get("apellido_paterno");
         $new_datos_profesor->apellido_materno = Input::get("apellido_materno");
         $new_datos_profesor->celular = Input::get("celular");
         if ($new_datos_profesor->validate(array('nombre' => 'required', 'apellido_paterno' => 'required', 'apellido_materno' => 'required', 'celular' => 'required|digits:10'))) {
             if ($new_profesor->updateUniques()) {
                 $new_datos_profesor->forceSave();
                 return Response::json(array('success' => true));
             } else {
                 return Response::json(array('success' => false, 'errores' => $new_profesor->errors()->toArray()));
             }
         } else {
             return Response::json(array('success' => false, 'errores' => $new_datos_profesor->errors()->toArray()));
         }
     }
 }