The Messenger of Allah (ﷺ) forbade these two plants (i.e. garlic and onions), and he said…

Sunan Abu Dawud Book 28 Hadith 92

Sunan Abu Dawud #3827

Foods (Kitab Al-At'imah) 28:92

Narrated Mu'awiyah ibn Qurrah:

The Messenger of Allah (ﷺ) forbade these two plants (i.e. garlic and onions), and he said: He who eats them should not come near our mosque. If it is necessary to eat them, make them dead by cooking, that is, onions and garlic.

Chapter: Regarding eating garlic

Grade: Sahih (Al-Albani)