During the holy battle of Khaibar the Prophet (ﷺ) said, "Whoever ate from this plant (i.e. garlic) should not enter our mosque."
Sahih al-Bukhari Book 10, Hadith 244