public function findOtherInvitationsQuery(UserInterface $user)
    {
        $qb = $this->createQueryBuilder('i');

        return $qb
            ->join('i.event', 'e')

            // Add conditions.
            ->andWhere($qb->expr()->eq('e.active', ':active'))
            ->andWhere($qb->expr()->orX(
                $qb->expr()->lt('e.end', ':now'),
                $qb->expr()->isNotNull('i.response')
            ))
            ->andWhere($qb->expr()->eq('i.invitee', ':invitee'))

            // Add parameters.
            ->setParameter('active', true)
            ->setParameter('now', new \DateTime())
            ->setParameter('invitee', $user->getUsername())

            // Add order by.
            ->addOrderBy('e.end', 'DESC')

            // Get query.
            ->getQuery();
    }
public function findOtherInvitationsQuery(UserInterface $user)
    {
        $qb = $this->createQueryBuilder('i');

        return $qb
            ->join('i.event', 'e')

            // Add conditions.
            ->andWhere($qb->expr()->eq('e.active', ':active'))
            ->andWhere($qb->expr()->orX(
                $qb->expr()->lt('e.end', ':now'),
                $qb->expr()->isNotNull('i.response')
            ))
            ->andWhere($qb->expr()->eq('i.invitee', ':invitee'))

            // Add parameters.
            ->setParameter('active', true)
            ->setParameter('now', new \DateTime())
            ->setParameter('invitee', $user->getUsername())

            // Add order by.
            ->addOrderBy('e.end', 'DESC')

            // Get query.
            ->getQuery();
    }
public function findOtherInvitationsQuery ( UserInterface $ user ) { $ qb = $ this -> createQueryBuilder ( 'i' ) ; return $ qb -> join ( 'i.event' , 'e' ) // Add conditions. -> andWhere ( $ qb -> expr ( ) -> eq ( 'e.active' , ':active' ) ) -> andWhere ( $ qb -> expr ( ) -> orX ( $ qb -> expr ( ) -> lt ( 'e.end' , ':now' ) , $ qb -> expr ( ) -> isNotNull ( 'i.response' ) ) ) -> andWhere ( $ qb -> expr ( ) -> eq ( 'i.invitee' , ':invitee' ) ) // Add parameters. -> setParameter ( 'active' , true ) -> setParameter ( 'now' , new \ DateTime ( ) ) -> setParameter ( 'invitee' , $ user -> getUsername ( ) ) // Add order by. -> addOrderBy ( 'e.end' , 'DESC' ) // Get query. -> getQuery ( ) ; }
Build query to find other invitations for a user.

@param UserInterface $user The user to find invitations for.

@return Invitation[]
Build query to find other invitations for a user .