It is narrated from Haram bin Muhayyisa, who narrated from Bara bin Azib (may Allah be pleased with him), that the she-camel of Bara bin Azib (may Allah be pleased with him) entered the garden of an Ansari and destroyed it. So the Messenger of Allah (ﷺ) gave the verdict that it is obligatory upon the owners of the gardens to guard them during the day, and whatever damage the cattle cause at night, its compensation is upon the owners of the cattle.
Hadith Referenceمسند الإمام الشافعي / كتاب القضاء والأحكام والدعاوى والبينات واليمين ومع الشاهد والأيمان والشهادات / 1692
Hadith Takhrijاخرجه ابوداود، البيوع، باب المواشى تفسد زرع قوم، رقم: 3570 - وابن ماجة ، الأحكام، باب الحكم فيما افسدت المواشي، رقم : 2332 - صححه الحاكم: 22 / 47 48 - ووافقه الذهبي والالباني في الصحيحة (238)۔