findBy([], ['dateHeureDebut' => 'DESC'], 5); $token = $tokenStorage->getToken(); $userConnect = $token?->getUser(); $dateLimit = new \DateTime(); $dateLimit->modify('-30 days'); // Date limite = il y a 30 jours $pastEvents = $sortieRepository->createQueryBuilder('s') ->where('s.dateHeureDebut < :now') ->andWhere('s.dateHeureDebut >= :dateLimit') ->setParameter('now', new \DateTime()) ->setParameter('dateLimit', $dateLimit) ->orderBy('s.dateHeureDebut', 'DESC') ->getQuery() ->getResult(); return $this->render('main/home.html.twig', [ 'lastSorties' => $latestSorties, 'profile' => $userConnect, 'pastEvents' => $pastEvents, ]); } #[Route('/dashboard', name: 'dashboard')] public function dashboard( TokenStorageInterface $tokenStorage, SortieRepository $sortieRepository, Request $request ): Response { $token = $tokenStorage->getToken(); $userConnect = $token?->getUser(); $sorties = $sortieRepository->findForDashboard(); $sortiesParticipation = $sortieRepository->findUserParticipation($userConnect); $sortiesOrganisation = $sortieRepository->findUserOrganisation($userConnect); return $this->render('main/dashboard.html.twig', [ 'profile' => $userConnect, 'sorties' => $sorties, 'sortiesParticipation' => $sortiesParticipation, 'sortiesOrganisation' => $sortiesOrganisation, ]); } #[Route('/inscription', name: 'inscription')] public function inscription(TokenStorageInterface $tokenStorage): Response { return $this->render('main/inscription.html.twig'); } #[Route('/participants', name: 'participants')] public function participants(TokenStorageInterface $tokenStorage, ParticipantRepository $participantRepository): Response { $token = $tokenStorage->getToken(); $userConnect = $token?->getUser(); return $this->render('main/participants.html.twig', [ 'profile' => $userConnect, 'participants' => $participantRepository->findAll(), ]); } }