26 lines
495 B
PHP
26 lines
495 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KupShop\QuantityDiscountBundle\Query;
|
|
|
|
use Query\Operator;
|
|
|
|
class QuantityDiscount
|
|
{
|
|
public static function byGroup(bool|int $groupId, ?string $alias = null): callable
|
|
{
|
|
$field = 'id_group';
|
|
|
|
if ($alias) {
|
|
$field = $alias.'.'.$field;
|
|
}
|
|
|
|
if (!is_bool($groupId)) {
|
|
return Operator::equals([$field => $groupId]);
|
|
}
|
|
|
|
return Operator::equalsNullable([$field => null]);
|
|
}
|
|
}
|