HEX
Server: LiteSpeed
System: Linux server315.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: globfdxw (6114)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //home/globfdxw/www/wp-content/plugins/give/src/Framework/QueryBuilder/Concerns/UnionOperator.php
<?php

namespace Give\Framework\QueryBuilder\Concerns;

use Give\Framework\QueryBuilder\Clauses\Union;
use Give\Framework\QueryBuilder\QueryBuilder;

/**
 * @since 2.19.0
 */
trait UnionOperator
{
    /**
     * @var int
     */
    protected $unions = [];

    /**
     * @param  QueryBuilder  $union
     *
     * @return $this
     */
    public function union(...$union)
    {
        $this->unions = array_map(function (QueryBuilder $builder) {
            return new Union($builder);
        }, $union);

        return $this;
    }

    /**
     * @param  QueryBuilder  $union
     *
     * @return $this
     */
    public function unionAll(...$union)
    {
        $this->unions = array_map(function (QueryBuilder $builder) {
            return new Union($builder, true);
        }, $union);

        return $this;
    }

    /**
     * @return array|string[]
     */
    protected function getUnionSQL()
    {
        if (empty($this->unions)) {
            return [];
        }

        return array_map(function (Union $union) {
            return ( $union->all ? 'UNION ALL ' : 'UNION ' ) . $union->builder->getSQL();
        }, $this->unions);
    }
}