feat: news messages to be displayed on teamers' dashboards

This commit is contained in:
Björn Fromme
2024-06-23 18:37:33 +02:00
parent b58bd9f34f
commit fbad0d4e06
18 changed files with 505 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Repository;
use App\Entity\News;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<News>
*/
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()
;
}
}