Abdullah bin Umar reported,

The Messenger of Allah ﷺ said during the expedition of Khaybar, "Whoever eats from this plant," meaning garlic, "should not come to the mosques."Zuhayr said, "during an expedition," and did not mention Khaybar.

Muslim 1248

Sahih

حدثنا محمد بن المثنى وزهير بن حرب قالا حدثنا يحيى وهو القطان عن عبيد الله قال أخبرني نافع

عن ابن عمر

أن رسول الله ﷺ قال في غزوة خيبر من أكل من هذه الشجرة يعني الثوم فلا يأتين المساجد قال زهير في غزوة ولم يذكر خيبر

مسلم 1248صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Mosques and places of prayer
Chapter
Prohibition on those who have eaten garlic, onions, leeks, or similar from attending the masjid
Numbering
Darussalam 1248
Muslim 1248