From 777a95728b025a299da3a2f4fb6839f932734c67 Mon Sep 17 00:00:00 2001 From: Ryan Prather Date: Sat, 30 Nov 2024 19:59:22 -0500 Subject: [PATCH] Add methods to retrieve different job types within company --- src/Repository/UserRepository.php | 42 +++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index ddc90cd..06c01a0 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -2,6 +2,7 @@ namespace App\Repository; +use App\Entity\Company; use App\Entity\User; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; @@ -33,11 +34,48 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader $this->getEntityManager()->flush(); } - public function getCaseManagers(): array + public function getCaseManagers(Company $company): array + { + return $this->createQueryBuilder('u') + ->andWhere('u.job != :job') + ->andWhere('u.company = :company') + ->setParameter('job', 'CASE_WORKER') + ->setParameter('company', $company->getId()->toBinary()) + ->getQuery() + ->getResult() + ; + } + + public function getTherapists(Company $company): array { return $this->createQueryBuilder('u') ->andWhere('u.job = :job') - ->setParameter('job', 'CASE_MANAGER') + ->andWhere('u.company = :company') + ->setParameter('job', 'THERAPIST') + ->setParameter('company', $company->getId()->toBinary()) + ->getQuery() + ->getResult() + ; + } + + public function getAdmins(Company $company): array + { + return $this->createQueryBuilder('u') + ->andWhere('u.job = :job') + ->andWhere('u.company = :company') + ->setParameter('job', 'ADMIN') + ->setParameter('company', $company->getId()->toBinary()) + ->getQuery() + ->getResult() + ; + } + + public function getCompanyUsers(Company $company): array + { + return $this->createQueryBuilder('u') + ->andWhere('u.company = :company') + ->setParameter('company', $company->getId()->toBinary()) + ->orderBy('u.name', 'ASC') ->getQuery() ->getResult() ;