The Prophet ﷺ said: Fighting is of two kinds: The one who seeks Allah's favour, obeys the leader, gives the property he values, treats his associates gently and avoids doing mischief, will have the reward for all the time whether he is asleep or awake; but the one who fights in a boasting spirit, for the sake of display and to gain a reputation, who disobeys the leader and does mischief in the earth will not return credit or without blame. (Using translation from Abū Dāʾūd 2515)
عَنْ رَسُولِ اللهِ ﷺ أَنَّهُ قَالَ «الْغَزْوُ غَزْوَانِ فَأَمَّا مَنِ ابْتَغَى وَجْهَ اللهِ وَأَطَاعَ الْإِمَامَ وَأَنْفَقَ الْكَرِيمَةَ وَيَاسَرَ الشَّرِيكَ وَاجْتَنَبَ الْفَسَادَ فَإِنَّ نَوْمَهُ وَنُبْهَهُ أَجْرٌ كُلُّهُ وَأَمَّا مَنْ غَزَا رِيَاءً وَسُمْعَةً وَعَصَى الْإِمَامَ وَأَفْسَدَ فِي الْأَرْضِ فَإِنَّهُ لَا يَرْجِعُ بِالْكَفَافِ»