des trucs
This commit is contained in:
@@ -13,8 +13,35 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class MainController extends AbstractController
|
||||
{
|
||||
|
||||
#[Route('/', name: 'home')]
|
||||
public function index(
|
||||
public function home(SortieRepository $sortieRepository, TokenStorageInterface $tokenStorage,): Response
|
||||
{
|
||||
// Récupérer les 5 dernières sorties
|
||||
$latestSorties = $sortieRepository->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
|
||||
|
||||
Reference in New Issue
Block a user