54 lines
1.9 KiB
PHP
54 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Repository\ParticipantRepository;
|
|
use App\Repository\SiteRepository;
|
|
use App\Repository\SortieRepository;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
class MainController extends AbstractController
|
|
{
|
|
#[Route('/', name: 'home')]
|
|
public function index(
|
|
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(),
|
|
]);
|
|
}
|
|
}
|