From c05bc4acbadc1fc24bab65ed8463e6ac41929b28 Mon Sep 17 00:00:00 2001 From: Jon Waldstein Date: Thu, 7 Dec 2023 11:22:31 -0500 Subject: [PATCH 1/2] fix: compensate for donors without donations --- src/Donors/CustomFields/Controllers/DonorDetailsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Donors/CustomFields/Controllers/DonorDetailsController.php b/src/Donors/CustomFields/Controllers/DonorDetailsController.php index 73754da18c..f77564833e 100644 --- a/src/Donors/CustomFields/Controllers/DonorDetailsController.php +++ b/src/Donors/CustomFields/Controllers/DonorDetailsController.php @@ -45,7 +45,7 @@ protected function getUniqueDonationFormsForDonor(Donor $donor): array { $formIds = array_map(static function (Donation $donation) { return $donation->formId; - }, $donor->donations); + }, $donor->donations ?? []); $formIds = array_filter($formIds, static function ($formId) { return !give(DonationFormRepository::class)->isLegacyForm($formId); From 0455ede6ed514f9415482fa647c0d1919b17e87b Mon Sep 17 00:00:00 2001 From: Jon Waldstein Date: Thu, 7 Dec 2023 11:39:51 -0500 Subject: [PATCH 2/2] refactor: use donations method instead --- src/Donors/CustomFields/Controllers/DonorDetailsController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Donors/CustomFields/Controllers/DonorDetailsController.php b/src/Donors/CustomFields/Controllers/DonorDetailsController.php index f77564833e..9258d69ddf 100644 --- a/src/Donors/CustomFields/Controllers/DonorDetailsController.php +++ b/src/Donors/CustomFields/Controllers/DonorDetailsController.php @@ -35,6 +35,7 @@ public function show(Donor $donor): string } /** + * @unreleased added array fallback when no donations are found * @since 3.0.0 * * @param Donor $donor @@ -45,7 +46,7 @@ protected function getUniqueDonationFormsForDonor(Donor $donor): array { $formIds = array_map(static function (Donation $donation) { return $donation->formId; - }, $donor->donations ?? []); + }, $donor->donations()->getAll() ?? []); $formIds = array_filter($formIds, static function ($formId) { return !give(DonationFormRepository::class)->isLegacyForm($formId);