Abu Saeed Khudri reported,

The Messenger of Allah ﷺ passed by an onion field along with his companions. Some of them dismounted and ate from it, while others did not eat. When we came to him later, he called forward those who had not eaten the onions and kept the others back until the smell had gone.

Muslim 1257

Sahih

حدثنا هارون بن سعيد الأيلي وأحمد بن عيسى قالا حدثنا ابن وهب أخبرني عمرو عن بكير بن الأشج عن ابن خباب

عن أبي سعيد الخدري

أن رسول الله ﷺ مر على زراعة بصل هو وأصحابه فنزل ناس منهم فأكلوا منه ولم يأكل آخرون فرحنا إليه فدعا الذين لم يأكلوا البصل وأخر الآخرين حتى ذهب ريحها

مسلم 1257صحيح
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 1257
Muslim 1257