feat : add repository queries for contract end notifications
This commit is contained in:
@@ -72,6 +72,24 @@ final class EmployeeContractPeriodRepository extends ServiceEntityRepository imp
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Latest contract period (max startDate) for every employee that has at least one.
|
||||||
|
*
|
||||||
|
* @return EmployeeContractPeriod[]
|
||||||
|
*/
|
||||||
|
public function findLatestPeriodsForAllEmployees(): array
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('p')
|
||||||
|
->andWhere('p.startDate = (
|
||||||
|
SELECT MAX(p2.startDate)
|
||||||
|
FROM App\Entity\EmployeeContractPeriod p2
|
||||||
|
WHERE p2.employee = p.employee
|
||||||
|
)')
|
||||||
|
->getQuery()
|
||||||
|
->getResult()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
public function closeOpenPeriods(Employee $employee, DateTimeImmutable $endDate): int
|
public function closeOpenPeriods(Employee $employee, DateTimeImmutable $endDate): int
|
||||||
{
|
{
|
||||||
return $this->createQueryBuilder('p')
|
return $this->createQueryBuilder('p')
|
||||||
|
|||||||
@@ -84,4 +84,28 @@ final class NotificationRepository extends ServiceEntityRepository
|
|||||||
->execute()
|
->execute()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function existsForRecipientCategoryTargetMessage(
|
||||||
|
User $recipient,
|
||||||
|
string $category,
|
||||||
|
string $target,
|
||||||
|
string $message,
|
||||||
|
): bool {
|
||||||
|
$id = $this->createQueryBuilder('n')
|
||||||
|
->select('n.id')
|
||||||
|
->andWhere('n.recipient = :recipient')
|
||||||
|
->andWhere('n.category = :category')
|
||||||
|
->andWhere('n.target = :target')
|
||||||
|
->andWhere('n.message = :message')
|
||||||
|
->setParameter('recipient', $recipient)
|
||||||
|
->setParameter('category', $category)
|
||||||
|
->setParameter('target', $target)
|
||||||
|
->setParameter('message', $message)
|
||||||
|
->setMaxResults(1)
|
||||||
|
->getQuery()
|
||||||
|
->getOneOrNullResult()
|
||||||
|
;
|
||||||
|
|
||||||
|
return null !== $id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user