// check if individual code.
// if we dont have a promotion Id only
// check if its existing somewhere,
// if we have an Id, verify if it's existing in another promotion
$query =
$qb ->
select('COUNT(*)'
) ->
from('promotion_individual_code'
) ->
where($qb->
expr()->
eq('code', ':code'
)) ->
setParameter('code',
$code);
if ($promotionId !== null
) { $query->
andWhere($qb->
expr()->
neq('promotion_id', ':promotion_id'
)) ->
setParameter('promotion_id',
$promotionId);
} $existingIndividual =
((int) $query->
executeQuery()->
fetchOne()) > 0;
if ($existingIndividual) { return true;
} $qb =
$this->connection->
createQueryBuilder();