From e874335fb152dd842c9d156809b9910f9844f8b7 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Rapha=C3=ABl=20Gertz?= <git@rapsys.eu>
Date: Mon, 19 Oct 2020 03:40:22 +0200
Subject: [PATCH] Add findAllByLocationDatePeriod function

---
 Repository/SessionRepository.php | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/Repository/SessionRepository.php b/Repository/SessionRepository.php
index 9ffaf02..b7471eb 100644
--- a/Repository/SessionRepository.php
+++ b/Repository/SessionRepository.php
@@ -42,4 +42,23 @@ class SessionRepository extends \Doctrine\ORM\EntityRepository {
 		//Send result
 		return $ret;
 	}
+
+	/**
+	 * Find sessions by location and date period
+	 *
+	 * @param $location The location
+	 * @param $period The date period
+	 */
+	public function findAllByLocationDatePeriod($location, $period) {
+		//Fetch sessions
+		$ret = $this->getEntityManager()
+			->createQuery('SELECT s FROM RapsysAirBundle:Session s WHERE (s.location = :location AND s.date BETWEEN :begin AND :end)')
+			->setParameter('location', $location)
+			->setParameter('begin', $period->getStartDate())
+			->setParameter('end', $period->getEndDate())
+			->getResult();
+
+		//Send result
+		return $ret;
+	}
 }
-- 
2.41.3