# give/4.16.9/src/Framework/Support/ValueObjects/EnumInteractsWithQueryBuilder.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.16.9. 56 lines.

- Page: https://pluginprobe.com/plugins/give/4.16.9/code/src/Framework/Support/ValueObjects/EnumInteractsWithQueryBuilder.php
- Raw: https://pluginprobe.com/plugins/give/4.16.9/raw/src/Framework/Support/ValueObjects/EnumInteractsWithQueryBuilder.php
- Modified: 2023-01-18T19:19:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.16.9/code/src/Framework/Support/ValueObjects/EnumInteractsWithQueryBuilder.php#L10-L20`.

```php
<?php

namespace Give\Framework\Support\ValueObjects;

use Give\Framework\Support\Facades\Str;

trait EnumInteractsWithQueryBuilder
{
    /**
     * @since 2.19.6
     *
     * Returns array of meta aliases to be used with attachMeta
     *
     * [ ['_give_payment_total', 'amount'], etc. ]
     *
     * @return array
     */
    public static function getColumnsForAttachMetaQuery()
    {
        $columns = [];

        foreach (static::toArray() as $key => $value) {
            $keyFormatted = Str::camel($key);

            $columns[] = [$value, $keyFormatted];
        }

        return $columns;
    }

    /**
     * @since 2.24.0
     *
     * Returns array of meta aliases to be used with attachMeta based on the given array of ENUMs
     *
     * [ ['_give_payment_total', 'amount'], etc. ]
     *
     * @param array<Enum> $enums An array of Enums. Eg.: [ DonationMetaKeys::AMOUNT(), etc. ]
     *
     * @return array
     */
    public static function getColumnsForAttachMetaQueryFromArray(array $enums): array
    {
        $columns = [];

        foreach ($enums as $enum) {
            $value = $enum->getValue();
            $keyFormatted = $enum->getKeyAsCamelCase();

            $columns[] = [$value, $keyFormatted];
        }

        return $columns;
    }
}

```
