Ubayy bin Ka'b (May Allah be pleased with him) reported:
There was a man of the Ansar whose house was the farthest from the mosque. As far as I know, he never missed Salat (in congregation). It was said to him: "If you buy a donkey, you may ride upon it in the dark nights and in the hot days." He said: "I do not like that my house should be situated close to the mosque. I desire that my walking towards the mosque and returning home be recorded to my credit." Upon this the Messenger of Allah (ﷺ) said, "Allah has gathered all (rewards) for you."[Muslim].
App reference: Book 9, Hadith 65
Arabic/English book reference: Book 9, Hadith 1055