A unified approach to Miquel's theorem and its degenerations