Entity/Repositories/NotificationRepository.php
public function getLastNotificationDate($recipientId)
    {
        $qb = $this->getEntityManager()->createQueryBuilder()
            ->select('max(n.sent)')
            ->from("Azine\EmailBundle\Entity\Notification", 'n')
            ->andWhere('n.recipient_id = :recipientId')
            ->setParameter('recipientId', $recipientId);
        $results = $qb->getQuery()->execute();
        if (null === $results[0][1]) {
            // the user has not received any notifications yet ever
            $lastNotification = new \DateTime('@0');
        } else {
            $lastNotification = new \DateTime($results[0][1]);
        }

        return $lastNotification;
    }
public function getLastNotificationDate($recipientId)
    {
        $qb = $this->getEntityManager()->createQueryBuilder()
            ->select('max(n.sent)')
            ->from("Azine\EmailBundle\Entity\Notification", 'n')
            ->andWhere('n.recipient_id = :recipientId')
            ->setParameter('recipientId', $recipientId);
        $results = $qb->getQuery()->execute();
        if (null === $results[0][1]) {
            // the user has not received any notifications yet ever
            $lastNotification = new \DateTime('@0');
        } else {
            $lastNotification = new \DateTime($results[0][1]);
        }

        return $lastNotification;
    }
public function getLastNotificationDate ( $ recipientId ) { $ qb = $ this -> getEntityManager ( ) -> createQueryBuilder ( ) -> select ( 'max(n.sent)' ) -> from ( "Azine\EmailBundle\Entity\Notification" , 'n' ) -> andWhere ( 'n.recipient_id = :recipientId' ) -> setParameter ( 'recipientId' , $ recipientId ) ; $ results = $ qb -> getQuery ( ) -> execute ( ) ; if ( null === $ results [ 0 ] [ 1 ] ) { // the user has not received any notifications yet ever $ lastNotification = new \ DateTime ( '@0' ) ; } else { $ lastNotification = new \ DateTime ( $ results [ 0 ] [ 1 ] ) ; } return $ lastNotification ; }
Get the \DateTime of the last Notification that has been sent.

@param $recipientId

@return \DateTime
Get the \ DateTime of the last Notification that has been sent .