diff --git a/src/Controller/SortieController.php b/src/Controller/SortieController.php index 45f8ccb..287683b 100644 --- a/src/Controller/SortieController.php +++ b/src/Controller/SortieController.php @@ -89,6 +89,10 @@ class SortieController extends AbstractController $this->addFlash('error', 'Cette sortie n\'existe pas.'); return $this->redirectToRoute('home'); } + if ($sortie->getDateHeureDebut() < (new DateTime())->modify('-1 month')) { + $this->addFlash('error', "Cette sortie à plus de 30 jours."); + return $this->redirectToRoute('home'); + } return $this->render('sortie/view.html.twig', [ 'sortie' => $sortie, diff --git a/templates/main/index.html.twig b/templates/main/index.html.twig index 3f7c400..1ea49aa 100644 --- a/templates/main/index.html.twig +++ b/templates/main/index.html.twig @@ -92,18 +92,17 @@ {% for sortie in sorties %} -
- Date de début : {{ sortie.dateHeureDebut|date('d/m/Y H:i') }}
- Durée : {{ sortie.duree }} minutes
- Inscriptions max : {{ sortie.nbInscriptionsMax }}
- Infos : {{ sortie.infosSortie }}
-
+ Date de début : {{ sortie.dateHeureDebut|date('d/m/Y H:i') }}
+ Durée : {{ sortie.duree }} minutes
+ Inscriptions max : {{ sortie.nbInscriptionsMax }}
+ Infos : {{ sortie.infosSortie }}
+
Aucune sortie ne correspond à vos critères.
{% endfor %}