$85 GRAYBYTE WORDPRESS FILE MANAGER $99

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.15.130 | ADMIN IP 216.73.216.51
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/home/bravetechrwanda/itiministry.org/plugins/give/src/DonationForms/Actions/

HOME
Current File : /home/bravetechrwanda/itiministry.org/plugins/give/src/DonationForms/Actions//GetOrCreateDonor.php
<?php

namespace Give\DonationForms\Actions;

use Exception;
use Give\Donors\Models\Donor;

/**
 * @since 3.2.0
 */
class GetOrCreateDonor
{
    public $donorCreated = false;

    /**
     * @since 3.9.0 Add support to "phone" property
     * @since 3.2.0
     *
     * @throws Exception
     */
    public function __invoke(
        ?int $userId,
        string $donorEmail,
        string $firstName,
        string $lastName,
        ?string $honorific,
        ?string $donorPhone
    ): Donor {
        // first check if donor exists as a user
        $donor = $userId ? Donor::whereUserId($userId) : null;

        // if they exist as a donor & user then make sure they don't already own this email before adding to their additional emails list..
        if ($donor && !$donor->hasEmail($donorEmail) && !Donor::whereEmail($donorEmail)) {
            $donor->additionalEmails = array_merge($donor->additionalEmails ?? [], [$donorEmail]);
            $donor->save();
        }

        // if donor is not a user than check for any donor matching this email
        if (!$donor) {
            $donor = Donor::whereEmail($donorEmail);
        }

        // if they exist as a donor & user but don't have a phone number then add it to their profile.
        if ($donor && empty($donor->phone)) {
            $donor->phone = $donorPhone;
            $donor->save();
        }

        // if no donor exists then create a new one using their personal information from the form.
        if (!$donor) {
            $donor = Donor::create([
                'name' => trim("$firstName $lastName"),
                'firstName' => $firstName,
                'lastName' => $lastName,
                'email' => $donorEmail,
                'phone' => $donorPhone,
                'userId' => $userId ?: null,
                'prefix' => $honorific,
            ]);

            $this->donorCreated = true;
        }

        return $donor;
    }
}

Current_dir [ WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
25 May 2026 4.20 PM
bravetechrwanda / bravetechrwanda
0755
AddHoneyPotFieldToDonationForms.php
1.255 KB
17 Oct 2024 5.45 AM
bravetechrwanda / bravetechrwanda
0644
ConvertConsentBlockToFieldsApi.php
1.732 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
ConvertDonationAmountBlockToFieldsApi.php
7.838 KB
1 Oct 2025 3.37 PM
bravetechrwanda / bravetechrwanda
0644
ConvertDonationFormBlocksToFieldsApi.php
15.739 KB
25 Feb 2026 10.24 PM
bravetechrwanda / bravetechrwanda
0644
ConvertQueryDataToDonationForm.php
1.104 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
DispatchDonateControllerDonationCreatedListeners.php
1.137 KB
28 Aug 2024 10.13 PM
bravetechrwanda / bravetechrwanda
0644
DispatchDonateControllerSubscriptionCreatedListeners.php
0.569 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
GenerateAuthUrl.php
0.527 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
GenerateDonateRouteSignatureArgs.php
0.489 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
GenerateDonateRouteUrl.php
0.521 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
GenerateDonationConfirmationReceiptUrl.php
0.607 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
GenerateDonationConfirmationReceiptViewRouteUrl.php
0.411 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
GenerateDonationFormPreviewRouteUrl.php
0.367 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
GenerateDonationFormValidationRouteUrl.php
0.573 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
GenerateDonationFormViewRouteUrl.php
0.369 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
GetOrCreateDonor.php
1.896 KB
24 Apr 2024 7.56 PM
bravetechrwanda / bravetechrwanda
0644
PrintFormMetaTags.php
0.761 KB
17 Oct 2024 5.45 AM
bravetechrwanda / bravetechrwanda
0644
ReplaceGiveReceiptShortcodeViewWithDonationConfirmationIframe.php
0.746 KB
28 Aug 2024 10.13 PM
bravetechrwanda / bravetechrwanda
0644
SanitizeDonationFormPreviewRequest.php
0.328 KB
11 Jan 2024 12.22 AM
bravetechrwanda / bravetechrwanda
0644
StoreBackwardsCompatibleFormMeta.php
6.081 KB
15 May 2024 7.28 PM
bravetechrwanda / bravetechrwanda
0644
ValidateReceiptViewPermission.php
0.779 KB
31 Mar 2025 11.17 PM
bravetechrwanda / bravetechrwanda
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF Static GIF