Add methods to retrieve different job types within company

This commit is contained in:
Ryan Prather 2024-11-30 19:59:22 -05:00
parent 20b67f86e5
commit 777a95728b

View File

@ -2,6 +2,7 @@
namespace App\Repository; namespace App\Repository;
use App\Entity\Company;
use App\Entity\User; use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
@ -33,11 +34,48 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
$this->getEntityManager()->flush(); $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') return $this->createQueryBuilder('u')
->andWhere('u.job = :job') ->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() ->getQuery()
->getResult() ->getResult()
; ;