Add descending sorting for tournament list

This commit is contained in:
Aleksandr Zaitsev 2024-03-11 17:57:13 +02:00
parent d58dfd022d
commit ee52d3dbdb

View File

@ -6,6 +6,7 @@ use App\Entity\Tournament;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Order;
use Doctrine\Persistence\ManagerRegistry;
/**
@ -38,6 +39,7 @@ class TournamentRepository extends ServiceEntityRepository
public function getTournamentList(int $page = 0): Collection
{
$query = $this->createQueryBuilder('t')
->orderBy('t.createdAt', Order::Descending->value)
->setFirstResult(self::TOURNAMENT_PER_PAGE * $page)
->setMaxResults(self::TOURNAMENT_PER_PAGE);
return new ArrayCollection($query->getQuery()->getResult());