Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

59 linhas
2.2KB

  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use Lc\ShopBundle\Context\DefaultRepositoryInterface;
  4. use Lc\ShopBundle\Context\ProductInterface;
  5. use Lc\ShopBundle\Context\ReminderInterface;
  6. /**
  7. * @method ReminderInterface|null find($id, $lockMode = null, $lockVersion = null)
  8. * @method ReminderInterface|null findOneBy(array $criteria, array $orderBy = null)
  9. * @method ReminderInterface[] findAll()
  10. * @method ReminderInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  11. */
  12. class ReminderRepository extends BaseRepository implements DefaultRepositoryInterface
  13. {
  14. public function getInterfaceClass()
  15. {
  16. return ReminderInterface::class;
  17. }
  18. public function findByUser($user)
  19. {
  20. $qb = $this->findByMerchantQuery()
  21. ->leftJoin('e.users', 'u')
  22. ->having('COUNT(u.id) = 0')
  23. ->orHaving(':user MEMBER OF e.users')
  24. ->andWhere('e.done = 0')
  25. ->setParameter('user', $user)
  26. ->orderBy('e.dateReminder', 'ASC')
  27. ->groupBy('e.id');
  28. return $qb->getQuery()->getResult();
  29. }
  30. public function findByEasyAdminConfigAndUser($action, $entity, $user, $id = null)
  31. {
  32. $qb = $this->findByMerchantQuery();
  33. $qb->leftJoin('e.users', 'u');
  34. $qb->having('COUNT(u.id) = 0');
  35. $qb->orHaving(':user MEMBER OF e.users');
  36. $qb->andWhere('e.done = 0');
  37. $qb->andWhere('e.entityAction LIKE :action');
  38. $qb->andWhere('e.entityName LIKE :entity');
  39. $qb->setParameter('entity', $entity);
  40. $qb->setParameter('action', $action);
  41. $qb->setParameter('user', $user);
  42. if ($id) {
  43. $qb->andWhere('e.entityId LIKE :id');
  44. $qb->setParameter('id', $id);
  45. }
  46. $qb->orderBy('e.dateReminder', 'ASC');
  47. $qb->groupBy('e.id');
  48. return $qb->getQuery()->getResult();
  49. }
  50. }