← Back
Editing: AddressReminderRepository.php
<?php namespace App\Repository; use App\Entity\AddressReminder; use App\Entity\User; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; /** * @method AddressReminder|null find($id, $lockMode = null, $lockVersion = null) * @method AddressReminder|null findOneBy(array $criteria, array $orderBy = null) * @method AddressReminder[] findAll() * @method AddressReminder[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class AddressReminderRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, AddressReminder::class); } public function findToRemind(?User $user) { $qb = $this->createQueryBuilder('a'); return $this->createQueryBuilder('a') ->leftJoin('a.address', 'ad') ->leftJoin('ad.userAddresses', 'ua') ->andWhere($qb->expr()->orX('ua.startDate <= :currentDate', 'ua.startDate is null')) ->andWhere($qb->expr()->orX('ua.endDate >= :currentDate', 'ua.endDate is null')) ->andWhere('a.done = :done') ->andWhere('ua.user = :user') ->setParameter('user', $user) ->setParameter('done', false) ->setParameter('currentDate', new \DateTime('today midnight')) ->getQuery() ->getResult(); } }
Save File
Cancel