Skip to content

Instantly share code, notes, and snippets.

@OneWeb
Last active January 11, 2019 08:36
Show Gist options
  • Save OneWeb/f73775c7b6b3f05d4713a9816d7aa248 to your computer and use it in GitHub Desktop.
Save OneWeb/f73775c7b6b3f05d4713a9816d7aa248 to your computer and use it in GitHub Desktop.
entry_check.php
<?php
//only one entry per household per brand
$totalEntries = $em
->createQuery("SELECT COUNT(e) FROM VcgEntryBundle:Entry e
INNER JOIN e.receipt r
WHERE LOWER(e.address1) = LOWER(:address1)
AND LOWER(e.town) = LOWER(:town)
AND r.status = 'approved'
AND e.product = :product")
->setParameter('address1', $entry->getAddress1())
->setParameter('town', $entry->getTown())
->setParameter('product', $entry->getProduct())
->getSingleScalarResult();
if ($totalEntries >= 1) {
$form->addError(new FormError('It looks like someone has already claimed for the product you chose from your household. This promotion is limited to one application per product per household.'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment