*/ class NotificationRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, Notification::class); } public function countUnreadByUser(User $user): int { return (int) $this->createQueryBuilder('n') ->select('COUNT(n.id)') ->where('n.user = :user') ->andWhere('n.isRead = false') ->setParameter('user', $user) ->getQuery() ->getSingleScalarResult() ; } public function markAllReadByUser(User $user): int { return $this->createQueryBuilder('n') ->update() ->set('n.isRead', 'true') ->where('n.user = :user') ->andWhere('n.isRead = false') ->setParameter('user', $user) ->getQuery() ->executeStatement() ; } }