feat: news messages to be displayed on teamers' dashboards
This commit is contained in:
@@ -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()
|
||||
;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user