feat: add Award entity and repository
This commit is contained in:
29
src/Repository/AwardRepository.php
Normal file
29
src/Repository/AwardRepository.php
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user