hesabixSite/src/Repository/AnswerVoteRepository.php
Hesabix 06a2fb398d
Some checks are pending
PHP Composer / build (push) Waiting to run
progress in site customer part
2025-09-05 09:37:27 +03:30

30 lines
812 B
PHP

<?php
namespace App\Repository;
use App\Entity\AnswerVote;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<AnswerVote>
*/
class AnswerVoteRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, AnswerVote::class);
}
public function findVoteByUserAndAnswer(int $userId, int $answerId): ?AnswerVote
{
return $this->createQueryBuilder('v')
->where('v.user = :userId')
->andWhere('v.answer = :answerId')
->setParameter('userId', $userId)
->setParameter('answerId', $answerId)
->getQuery()
->getOneOrNullResult();
}
}