mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
Add new methods to RegroupmentRepository and fix association
Regroupment/Center
This commit is contained in:
@@ -14,6 +14,8 @@ namespace Chill\MainBundle\Repository;
|
||||
use Chill\MainBundle\Entity\Regroupment;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\NonUniqueResultException;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
final class RegroupmentRepository implements ObjectRepository
|
||||
@@ -59,6 +61,30 @@ final class RegroupmentRepository implements ObjectRepository
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NonUniqueResultException
|
||||
* @throws NoResultException
|
||||
*/
|
||||
public function findOneByName(string $name): ?Regroupment
|
||||
{
|
||||
return $this->repository->createQueryBuilder('r')
|
||||
->where('LOWER(r.name) = LOWER(:searched)')
|
||||
->setParameter('searched', $name)
|
||||
->getQuery()
|
||||
->getSingleResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<Regroupment>
|
||||
*/
|
||||
public function findRegroupmentAssociatedToAnyCenter(): array
|
||||
{
|
||||
return $this->repository->createQueryBuilder('r')
|
||||
->where('SIZE(r.centers) = 0')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function getClassName()
|
||||
{
|
||||
return Regroupment::class;
|
||||
|
Reference in New Issue
Block a user