feat: add Award entity and repository

This commit is contained in:
thibaud-leclere
2026-04-01 14:23:23 +02:00
parent acc266739d
commit 859a5a1067
3 changed files with 124 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace App\Repository;
use App\Entity\Award;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/** @extends ServiceEntityRepository<Award> */
class AwardRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Award::class);
}
public function findOneRandomByActor(int $actorId): ?Award
{
return $this->createQueryBuilder('a')
->andWhere('a.actor = :actorId')
->setParameter('actorId', $actorId)
->orderBy('RANDOM()')
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
}
}