*/ 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', \SortDirection::Descending) ->addOrderBy('news.createdAt', \SortDirection::Descending) ->setParameter('status', News::STATUS_DEACTIVATED) ->setMaxResults(1) ->getQuery() ->getOneOrNullResult() ; } }