63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\Assignment;
|
|
use App\Entity\Teamer;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\ORM\Query;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @extends ServiceEntityRepository<Assignment>
|
|
*
|
|
* @method Assignment|null find($id, $lockMode = null, $lockVersion = null)
|
|
* @method Assignment|null findOneBy(array $criteria, array $orderBy = null)
|
|
* @method Assignment[] findAll()
|
|
* @method Assignment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
*/
|
|
class AssignmentRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, Assignment::class);
|
|
}
|
|
|
|
public function getListQuery(Teamer $teamer = null): Query
|
|
{
|
|
$qb = $this->createQueryBuilder('assignment');
|
|
|
|
$qb
|
|
->select('assignment', 'destination', 'job_profile', 'application')
|
|
->innerJoin('assignment.destination', 'destination')
|
|
->innerJoin('assignment.jobProfile', 'job_profile')
|
|
->leftJoin('assignment.applications', 'application')
|
|
;
|
|
|
|
if (null !== $teamer) {
|
|
$qb
|
|
->where($qb->expr()->eq('application.teamer', ':teamer'))
|
|
->setParameter('teamer', $teamer)
|
|
;
|
|
}
|
|
|
|
return $qb->getQuery();
|
|
}
|
|
|
|
public function getBookmarkQueryForTeamer(Teamer $teamer): Query
|
|
{
|
|
$qb = $this->createQueryBuilder('assignment');
|
|
|
|
$qb
|
|
->select('assignment', 'destination', 'job_profile')
|
|
->innerJoin('assignment.teamers', 'teamer', 'WITH', 'teamer = :teamer')
|
|
->innerJoin('assignment.destination', 'destination')
|
|
->innerJoin('assignment.jobProfile', 'job_profile')
|
|
->leftJoin('assignment.applications', 'application')
|
|
->setParameter('teamer', $teamer)
|
|
;
|
|
|
|
return $qb->getQuery();
|
|
}
|
|
}
|