1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace App\Repository;
use App\Entity\Groupeprestataire;
use App\Entity\Prestataire;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* @method Prestataire|null find($id, $lockMode = null, $lockVersion = null)
* @method Prestataire|null findOneBy(array $criteria, array $orderBy = null)
* @method Prestataire[] findAll()
* @method Prestataire[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class PrestataireRepository extends ServiceEntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, Prestataire::class);
}
/**
* @return Prestataire[] Returns an array of Prestataire objects
*/
public function findByGroupeprestataire(Groupeprestataire $groupe)
{
$qb = $this->createQueryBuilder('p');
return $qb
->where($qb->expr()->isMemberOf(':groupe', 'p.groupeprestataires'))
->andWhere('p.enabled = :enabled')
->setParameter('groupe', $groupe)
->setParameter('enabled', true)
->orderBy('p.raison', 'ASC')
->getQuery()
->getResult()
;
}
/**
* @return Prestataire[] Returns an array of Prestataire objects
*/
public function findbyExclude(Prestataire $presta)
{
$qb = $this->createQueryBuilder('p');
return $qb
->where('p.id != :presta')
->andWhere('p.enabled = :enabled')
->setParameter('presta', $presta->getId())
->setParameter('enabled', true)
->orderBy('p.raison', 'ASC')
->getQuery()
->getResult()
;
}
}