*/ class NewsRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, News::class); } public function getLatestForDashboard(): ?News { $qb = $this->createQueryBuilder('news'); return $qb ->where($qb->expr()->neq('news.status', ':status')) ->orderBy('news.status', 'DESC') ->addOrderBy('news.createdAt', 'DESC') ->setParameter('status', News::STATUS_DEACTIVATED) ->setMaxResults(1) ->getQuery() ->getOneOrNullResult() ; } }