PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / DonationForms / V2 / Models / DonationForm.php

DonationForm.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/DonationForms/V2/Models/DonationForm.php

106 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonationForms\V2\Models;
4
5 use DateTime;
6 use Give\DonationForms\Models\DonationForm as ModelsDonationForm;
7 use Give\DonationForms\Properties\GoalSettings;
8 use Give\DonationForms\V2\Actions\ConvertV2FormToV3Form;
9 use Give\DonationForms\V2\DataTransferObjects\DonationFormQueryData;
10 use Give\DonationForms\V2\Properties\DonationFormLevel;
11 use Give\DonationForms\V2\ValueObjects\DonationFormStatus;
12 use Give\Framework\Models\Contracts\ModelReadOnly;
13 use Give\Framework\Models\Model;
14 use Give\Framework\Models\ModelQueryBuilder;
15 use Give\Framework\Models\ValueObjects\Relationship;
16 use Give\Framework\Support\ValueObjects\Money;
17
18 /**
19 * Class DonationForm
20 *
21 * @since 2.24.0
22 *
23 * @property int $id
24 * @property string $title
25 * @property DonationFormLevel[] $levels
26 * @property bool $goalOption
27 * @property int $totalNumberOfDonations
28 * @property Money $totalAmountDonated
29 * @property DateTime $createdAt
30 * @property DateTime $updatedAt
31 * @property DonationFormStatus $status
32 * @since 4.3.0
33 * @property GoalSettings $goalSettings
34 * @property bool $usesFormBuilder
35 * @property int $campaignId
36 */
37 class DonationForm extends Model implements ModelReadOnly
38 {
39 /**
40 * @inheritdoc
41 */
42 protected $properties = [
43 'id' => 'int',
44 'title' => 'string',
45 'levels' => 'array',
46 'goalOption' => 'bool',
47 'totalNumberOfDonations' => 'int',
48 'totalAmountDonated' => Money::class,
49 'createdAt' => DateTime::class,
50 'updatedAt' => DateTime::class,
51 'status' => DonationFormStatus::class,
52 'goalSettings' => GoalSettings::class,
53 'usesFormBuilder' => 'bool',
54 'campaignId' => 'int',
55 ];
56
57 /**
58 * @inheritdoc
59 */
60 protected $relationships = [
61 'donations' => Relationship::HAS_MANY,
62 ];
63
64 /**
65 * @since 2.24.0
66 *
67 * @param $id
68 *
69 * @return DonationForm|null
70 */
71 public static function find($id)
72 {
73 return give()->donationForms->getById($id);
74 }
75
76 /**
77 * @since 2.24.0
78 *
79 * @return ModelQueryBuilder<DonationForm>
80 */
81 public static function query(): ModelQueryBuilder
82 {
83 return give()->donationForms->prepareQuery();
84 }
85
86 /**
87 * @since 2.24.0
88 *
89 * @param object $object
90 *
91 * @return DonationForm
92 */
93 public static function fromQueryBuilderObject($object): DonationForm
94 {
95 return DonationFormQueryData::fromObject($object)->toDonationForm();
96 }
97
98 /**
99 * @since 4.2.0
100 */
101 public function toV3Form(): ModelsDonationForm
102 {
103 return (new ConvertV2FormToV3Form($this))();
104 }
105 }
106