|
- <?php
-
- namespace Lc\SovBundle\Repository\Reminder;
-
- use Lc\SovBundle\Repository\AbstractRepository;
- use Lc\SovBundle\Model\Reminder\ReminderInterface;
-
- /**
- * @method ReminderInterface|null find($id, $lockMode = null, $lockVersion = null)
- * @method ReminderInterface|null findOneBy(array $criteria, array $orderBy = null)
- * @method ReminderInterface[] findAll()
- * @method ReminderInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- */
- class ReminderRepositoryBack extends AbstractRepository
- {
- public function getInterfaceClass()
- {
- return ReminderInterface::class;
- }
-
- public function findByUser($user)
- {
- $qb = $this->createQueryBuilder('e')
- ->leftJoin('e.users', 'u')
- ->having('COUNT(u.id) = 0')
- ->orHaving(':user MEMBER OF e.users')
- ->andWhere('e.done = 0')
- ->setParameter('user', $user)
- ->orderBy('e.dateReminder', 'ASC')
- ->groupBy('e.id');
-
- return $qb->getQuery()->getResult();
- }
-
- public function findByEasyAdminConfigAndUser($crudAction, $crudControllerFqcn, $user, $entityId = null)
- {
- $qb = $this->createQueryBuilder('e');
- $qb->leftJoin('e.users', 'u');
- $qb->having('COUNT(u.id) = 0');
- $qb->orHaving(':user MEMBER OF e.users');
- $qb->andWhere('e.done = 0');
- $qb->andWhere('e.crudAction LIKE :crudAction');
- $qb->andWhere('e.crudControllerFqcn LIKE :entity');
- $qb->setParameter('crudAction', $crudAction);
- $qb->setParameter('crudControllerFqcn', $crudControllerFqcn);
- $qb->setParameter('user', $user);
- if ($entityId) {
- $qb->andWhere('e.entityId LIKE :id');
- $qb->setParameter('entityId', $entityId);
- }
- $qb->orderBy('e.dateReminder', 'ASC');
- $qb->groupBy('e.id');
-
- return $qb->getQuery()->getResult();
- }
- }
|