*/ final class EmployeeRttPaymentRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, EmployeeRttPayment::class); } public function findOneByEmployeeYearMonth(Employee $employee, int $year, int $month): ?EmployeeRttPayment { return $this->findOneBy([ 'employee' => $employee, 'year' => $year, 'month' => $month, ]); } /** * @return EmployeeRttPayment[] */ public function findByEmployeeAndYear(Employee $employee, int $year): array { return $this->createQueryBuilder('p') ->andWhere('p.employee = :employee') ->andWhere('p.year = :year') ->setParameter('employee', $employee) ->setParameter('year', $year) ->addOrderBy('p.month', 'ASC') ->getQuery() ->getResult() ; } /** * @return EmployeeRttPayment[] */ public function findByYearAndMonth(int $year, int $month): array { return $this->createQueryBuilder('p') ->andWhere('p.year = :year') ->andWhere('p.month = :month') ->setParameter('year', $year) ->setParameter('month', $month) ->innerJoin('p.employee', 'e') ->addSelect('e') ->getQuery() ->getResult() ; } }