PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
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 / Framework / Support / ValueObjects / EnumInteractsWithQueryBuilder.php

EnumInteractsWithQueryBuilder.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/Framework/Support/ValueObjects/EnumInteractsWithQueryBuilder.php

56 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Framework\Support\ValueObjects;
4
5 use Give\Framework\Support\Facades\Str;
6
7 trait EnumInteractsWithQueryBuilder
8 {
9 /**
10 * @since 2.19.6
11 *
12 * Returns array of meta aliases to be used with attachMeta
13 *
14 * [ ['_give_payment_total', 'amount'], etc. ]
15 *
16 * @return array
17 */
18 public static function getColumnsForAttachMetaQuery()
19 {
20 $columns = [];
21
22 foreach (static::toArray() as $key => $value) {
23 $keyFormatted = Str::camel($key);
24
25 $columns[] = [$value, $keyFormatted];
26 }
27
28 return $columns;
29 }
30
31 /**
32 * @since 2.24.0
33 *
34 * Returns array of meta aliases to be used with attachMeta based on the given array of ENUMs
35 *
36 * [ ['_give_payment_total', 'amount'], etc. ]
37 *
38 * @param array<Enum> $enums An array of Enums. Eg.: [ DonationMetaKeys::AMOUNT(), etc. ]
39 *
40 * @return array
41 */
42 public static function getColumnsForAttachMetaQueryFromArray(array $enums): array
43 {
44 $columns = [];
45
46 foreach ($enums as $enum) {
47 $value = $enum->getValue();
48 $keyFormatted = $enum->getKeyAsCamelCase();
49
50 $columns[] = [$value, $keyFormatted];
51 }
52
53 return $columns;
54 }
55 }
56