feat: display new and pending feedbacks on admin dashboard
This commit is contained in:
@@ -21,21 +21,30 @@ class FeedbackRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Feedback::class);
|
||||
}
|
||||
|
||||
public function save(Feedback $entity, bool $flush = false): void
|
||||
public function getNew(int $limit = 5): array
|
||||
{
|
||||
$this->getEntityManager()->persist($entity);
|
||||
$qb = $this->createQueryBuilder('feedback');
|
||||
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
return $qb
|
||||
->select('feedback', 'teamer')
|
||||
->innerJoin('feedback.teamer', 'teamer')
|
||||
->orderBy('feedback.createdAt', 'DESC')
|
||||
->setMaxResults($limit)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
|
||||
public function remove(Feedback $entity, bool $flush = false): void
|
||||
public function getCountByStatus(string $status): int
|
||||
{
|
||||
$this->getEntityManager()->remove($entity);
|
||||
$qb = $this->createQueryBuilder('feedback');
|
||||
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
return $qb
|
||||
->select($qb->expr()->count('feedback'))
|
||||
->where($qb->expr()->eq('feedback.status', ':status'))
|
||||
->setParameter('status', $status)
|
||||
->getQuery()
|
||||
->getSingleScalarResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user