Repository/EventRepository.php
public function searchEvents(
        Production $production,
        \DateTime $from,
        \DateTime $to,
        bool $active = true
    ) {
        $qb = $this->createQueryBuilder('e');

        return $qb
            ->join('e.groups', 'g')

            // Add conditions.
            ->andWhere($qb->expr()->eq('g', ':group'))
            ->andWhere($qb->expr()->between('e.start', ':from', ':to'))
            ->andWhere($qb->expr()->eq('e.active', ':active'))

            // Add parameters.
            ->setParameter('group', $production)
            ->setParameter('from', $from)
            ->setParameter('to', $to)
            ->setParameter('active', $active)

            // Get results.
            ->getQuery()
            ->getResult();
    }
public function searchEvents(
        Production $production,
        \DateTime $from,
        \DateTime $to,
        bool $active = true
    ) {
        $qb = $this->createQueryBuilder('e');

        return $qb
            ->join('e.groups', 'g')

            // Add conditions.
            ->andWhere($qb->expr()->eq('g', ':group'))
            ->andWhere($qb->expr()->between('e.start', ':from', ':to'))
            ->andWhere($qb->expr()->eq('e.active', ':active'))

            // Add parameters.
            ->setParameter('group', $production)
            ->setParameter('from', $from)
            ->setParameter('to', $to)
            ->setParameter('active', $active)

            // Get results.
            ->getQuery()
            ->getResult();
    }
public function searchEvents ( Production $ production , \ DateTime $ from , \ DateTime $ to , bool $ active = true ) { $ qb = $ this -> createQueryBuilder ( 'e' ) ; return $ qb -> join ( 'e.groups' , 'g' ) // Add conditions. -> andWhere ( $ qb -> expr ( ) -> eq ( 'g' , ':group' ) ) -> andWhere ( $ qb -> expr ( ) -> between ( 'e.start' , ':from' , ':to' ) ) -> andWhere ( $ qb -> expr ( ) -> eq ( 'e.active' , ':active' ) ) // Add parameters. -> setParameter ( 'group' , $ production ) -> setParameter ( 'from' , $ from ) -> setParameter ( 'to' , $ to ) -> setParameter ( 'active' , $ active ) // Get results. -> getQuery ( ) -> getResult ( ) ; }
Search for events within a production.

@param Production $production The production to search in.
@param \DateTime  $from       The time to start searching from.
@param \DateTime  $to         The time to end searching from.
@param bool       $active     The active state of the events.

@return Event[]
Search for events within a production .