Files
myep-team/src/Repository/JobProfileRepository.php
T

51 lines
1.5 KiB
PHP

<?php
namespace App\Repository;
use App\Entity\JobProfile;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<JobProfile>
*
* @method JobProfile|null find($id, $lockMode = null, $lockVersion = null)
* @method JobProfile|null findOneBy(array $criteria, array $orderBy = null)
* @method JobProfile[] findAll()
* @method JobProfile[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class JobProfileRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, JobProfile::class);
}
public function getList(): array
{
$qb = $this->createQueryBuilder('job_profile');
return $qb
->select('job_profile', 'required_training')
->leftJoin('job_profile.requiredTrainings', 'required_training')
->where($qb->expr()->isNull('job_profile.deletedAt'))
->orderBy('job_profile.name', 'ASC')
->getQuery()
->getResult()
;
}
public function findByLicenseType(string $licenseType): array
{
$qb = $this->createQueryBuilder('job_profile');
return $qb
->where($qb->expr()->like('job_profile.requiredLicenses', ':licenseType'))
->orderBy('job_profile.name', 'ASC')
->setParameter('licenseType', '%'.$licenseType.'%')
->getQuery()
->getResult()
;
}
}