Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

57 lines
1.8KB

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