feat : add repository queries for contract end notifications

This commit is contained in:
2026-06-24 15:28:53 +02:00
parent 75c3438ea9
commit d5cf7c7058
2 changed files with 42 additions and 0 deletions
@@ -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
{
return $this->createQueryBuilder('p')
+24
View File
@@ -84,4 +84,28 @@ final class NotificationRepository extends ServiceEntityRepository
->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;
}
}