From e853743b01229b5599f12f6ab042a726b0493802 Mon Sep 17 00:00:00 2001 From: Olivier PARPAILLON Date: Mon, 25 Nov 2024 16:22:18 +0100 Subject: [PATCH] sortie > 1 month --- src/Controller/SortieController.php | 4 ++++ templates/main/index.html.twig | 21 ++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) 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 %} -
-

{{ sortie.nom }}

-

- Date de début : {{ sortie.dateHeureDebut|date('d/m/Y H:i') }}
- Durée : {{ sortie.duree }} minutes
- Inscriptions max : {{ sortie.nbInscriptionsMax }}
- Infos : {{ sortie.infosSortie }} -

- + {% else %}

Aucune sortie ne correspond à vos critères.

{% endfor %}