Macroscopic Nonlinear Optical Properties from Cavity Models