<?php
namespace App\Repository\GuardianRegister;
use App\Entity\GuardianRegister\GuardianRegister;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method GuardianRegister|null find($id, $lockMode = null, $lockVersion = null)
* @method GuardianRegister|null findOneBy(array $criteria, array $orderBy = null)
* @method GuardianRegister[] findAll()
* @method GuardianRegister[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class GuardianRegisterRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, GuardianRegister::class);
}
/**
* Creates a new QueryBuilder instance that is prepopulated for this entity name.
*
* @param string $alias
* @param string $indexBy The index for the from.
*
* @return QueryBuilder
*/
public function createQueryBuilder($alias, $indexBy = null)
{
return $this->_em->createQueryBuilder()
->select($alias)
->from($this->_entityName, $alias, $indexBy)
->andWhere("${alias}.isDeleted = 0");
}
public function countNewRegistrations(): int
{
return (int) $this->createQueryBuilder('gr')
->select('COUNT(gr.id)')
->andWhere('gr.status = :status')
->setParameter('status', GuardianRegister::STATUS_NEW['value'])
->getQuery()
->getSingleScalarResult();
}
// /**
// * @return GuardianRegister[] Returns an array of GuardianRegister objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('g')
->andWhere('g.exampleField = :val')
->setParameter('val', $value)
->orderBy('g.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?GuardianRegister
{
return $this->createQueryBuilder('g')
->andWhere('g.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}