30 lines
834 B
PHP
30 lines
834 B
PHP
<?php
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\QuestionVote;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @extends ServiceEntityRepository<QuestionVote>
|
|
*/
|
|
class QuestionVoteRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, QuestionVote::class);
|
|
}
|
|
|
|
public function findVoteByUserAndQuestion(int $userId, int $questionId): ?QuestionVote
|
|
{
|
|
return $this->createQueryBuilder('v')
|
|
->where('v.user = :userId')
|
|
->andWhere('v.question = :questionId')
|
|
->setParameter('userId', $userId)
|
|
->setParameter('questionId', $questionId)
|
|
->getQuery()
|
|
->getOneOrNullResult();
|
|
}
|
|
}
|