I am Muslim living in a bad environment I pray at home. Do I have to pray in the Masjid?
All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Performing obligatory prayers in congregation is an obligation upon every Muslim man according to many sound Ahadeeth.
For example, the Hadeeth narrated in Saheeh Muslim reads “A blind man came to the Prophet and said: “O Messenger of Allah! I have no one to guide me to the mosque can I pray at home? The Prophet granted him permission. When the man turned away, he called him and said: "Do you hear the call (the Athaan)?" The blind man said: "Yes." Thereupon, the Prophet said to him: "Answer the call; I do not find any excuse for you.” [Muslim]
There are many other Ahadeeth that support this ruling. Therefore, you are not permitted to offer prayers at home if you hear the call to prayer. Being in a bad environment does not permit you to neglect praying in congregation. A Muslim should perform all his religious obligations and keep his Islamic identity so that he becomes a model for others.
Allah knows best.
You can search for fatwa through many choices