I believe this is reported from the Prophet ﷺ, who said, "I saw in a dream that I was migrating from Mecca to a land containing date palms. My thoughts went to the idea that it was Yamamah or Hajar, but it turned out to be the city of Yathrib. In this same vision, I saw myself brandishing a sword, and its blade broke. That represented the believers who were struck down on the day of Uhud. Then I brandished it again, and it returned to a better state than before. That represented the victory Allah brought about and the gathering together of the believers. I also saw cattle in the dream, and what Allah brings is good. The cattle were the believers on the day of Uhud, and the good was what Allah brought of goodness and the reward of truthfulness that Allah granted us after the day of Badr."
حدثني محمد بن العلاء حدثنا حماد بن أسامة عن بريد بن عبد الله بن أبي بردة عن جده أبي بردة
أراه عن النبي ﷺ قال رأيت في المنام أني أهاجر من مكة إلى أرض بها نخل فذهب وهلي إلى أنها اليمامة أو هجر فإذا هي المدينة يثرب ورأيت في رؤياي هذه أني هززت سيفا فانقطع صدره فإذا هو ما أصيب من المؤمنين يوم أحد ثم هززته بأخرى فعاد أحسن ما كان فإذا هو ما جاء الله به من الفتح واجتماع المؤمنين ورأيت فيها بقرا والله خير فإذا هم المؤمنون يوم أحد وإذا الخير ما جاء الله به من الخير وثواب الصدق الذي آتانا الله بعد يوم بدر