The Prophet ﷺ said during the expedition of Khaybar, "Whoever has eaten from this plant," meaning garlic, "must not come near our mosque."
حدثنا مسدد قال حدثنا يحيى عن عبيد الله قال حدثني نافع
أن النبي ﷺ قال في غزوة خيبر من أكل من هذه الشجرة يعني الثوم فلا يقربن مسجدنا