In many classes of unconventional superconductors, the question of whether the superconductivity is enhanced by the quantum-critical fluctuations on the verge of an ordered phase remains elusive. One of the most direct ways of addressing this issue is to investigate how the superconducting dome traces a shift of the ordered phase. Here, we study how the phase diagram of the iron-based superconductor BaFe$_2$(As$_{1-x}$P$_x$)$_2$ changes with disorder via electron irradiation, which keeps the carrier concentrations intact. With increasing disorder, we find that the magneto-structural transition is suppressed, indicating that the critical concentration is shifted to the lower side. Although the superconducting transition temperature $T_c$ is depressed at high concentrations ($xgtrsim$0.28), it shows an initial increase at lower $x$. This implies that the superconducting dome tracks the shift of the antiferromagnetic phase, supporting the view of the crucial role played by quantum-critical fluctuations in enhancing superconductivity in this iron-based high-$T_c$ family.