src/Repository/FormulaireRepository.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use Doctrine\ORM\EntityRepository;
  4. use App\Entity\Center;
  5. /**
  6.  * FormulaireRepository
  7.  *
  8.  * This class was generated by the Doctrine ORM. Add your own custom
  9.  * repository methods below.
  10.  */
  11. class FormulaireRepository extends EntityRepository
  12. {
  13.     public function findAllWithFormation($center)
  14.     {
  15.         $query $this->createQueryBuilder('f');
  16.         $query->innerJoin('f.formations''formations')
  17.             ->innerJoin('formations.group''g')
  18.             ->innerJoin('g.center','c')
  19.             ->where('c = :center')
  20.             ->andWhere('f.isActive IS NOT NULL')
  21.             ->setParameter('center'$center);
  22.         if($center->getId() == 2){
  23.             $query->andWhere('f.id != :formationEnDouble')
  24.                 ->setParameter('formationEnDouble'158);
  25.         }
  26.         return $query->getQuery()->getResult();
  27.     }
  28.     public function findAllWithFormationWithCenter(Center $center)
  29.     {
  30.         $query $this->createQueryBuilder('f');
  31.         $query->select('f.name');
  32.         return $query->getQuery()->getResult();
  33.     }
  34.     public function findActiveAndMan(Center $center null): array
  35.     {
  36.         $query $this->createQueryBuilder('f');
  37.         $query->where('f.isActive = true')
  38.             ->orWhere('f.id = 150')
  39.             ->orWhere('f.id = 155')
  40.             ->orWhere('f.id = 156')
  41.             ->orWhere('f.id = 163')
  42.             ->orWhere('f.id = 164')
  43.             ->orWhere('f.id = 165');
  44.         if($center instanceof Center){
  45.             $query
  46.                 ->innerJoin('f.formations''formations')
  47.                 ->innerJoin('formations.group''g')
  48.                 ->innerJoin('g.center','c')
  49.                 ->where('c = :center')
  50.                 ->setParameter('center'$center);
  51.         }
  52.         return $query->getQuery()->getResult();
  53.     }
  54. }