Lady Umm Ayyub (may Allah be pleased with her) said that the Messenger of Allah (peace and blessings be upon him) stayed with us, so we prepared food for him with great care, in which there were some vegetables (such as garlic, onions, etc.). When we presented that food to the Messenger of Allah (peace and blessings be upon him), he did not like it and said to his companions: "You people eat, I am not like you. I fear that I may cause discomfort to my companion (Jibreel or the noble scribes)." Imam Darimi (may Allah have mercy on him) said: When it does not cause harm to anyone, that is, if garlic or onion does not cause discomfort, then there is no problem in eating it. That is, cooked food is permissible.
Hadith Referenceسنن دارمي / من كتاب الاطعمة / 2091
There are several other ahadith in this context in Sahihayn, in which it has been clearly commanded that whoever eats garlic, onion, or leek (kurrath), should not come near our mosques, rather should stay away.
The purpose of these ahadith is precisely this: that the foul odor produced in the mouth by eating these things raw is distressing to other worshippers. Therefore, those who eat these things should, by whatever means possible, remove their odor before coming to the mosque.
The same ruling applies to biri, cigarettes, hookah, tobacco, etc.