src/Controller/DefaultController.php line 18

Open in your IDE?
  1. <?php
  2. // src/Controller/LuckyController.php
  3. namespace App\Controller;
  4. use App\Entity\Matchs;
  5. use App\Entity\MatchsUser;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\HttpFoundation\RedirectResponse;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. class DefaultController extends AbstractController
  12. {
  13.     /**
  14.      * @Route("/", name="app_index")
  15.      */
  16.     public function index(EntityManagerInterface $em): Response
  17.     {
  18.         
  19.         return $this->render('default/index.html.twig', [
  20.             // 'matchs' => $matchs
  21.         ]);
  22.     }
  23.     /**
  24.      * @Route("/home", name="app_home")
  25.      */
  26.     public function home(EntityManagerInterface $em): Response
  27.     {
  28.         $matchs $em->getRepository(Matchs::class)->findActiveMatchs(); 
  29.         $users = [];
  30.         foreach ($matchs as $match) {
  31.             foreach ($match->getMatchsUsers() as $key => $matchsUsers) {
  32.                 /** @var MatchsUser $matchsUsers */
  33.                 $users[$match->getId()][$key] = $matchsUsers->getUser();
  34.             }
  35.         }
  36.         
  37.         $endedMatchs $em->getRepository(Matchs::class)->findEndedMatchs();
  38.         // dump($matchs);
  39.         // dd($endedMatchs);
  40.         return $this->render('home/index.html.twig', [
  41.             'matchs' => $matchs,
  42.             'endedMatchs' => $endedMatchs,
  43.             'users' => $users
  44.         ]);
  45.     }
  46.     /**
  47.      * @Route("/waiting", name="app_waiting")
  48.      */
  49.     public function waiting(EntityManagerInterface $em): Response
  50.     {
  51.         
  52.         return $this->render('home/waiting.html.twig');
  53.     }
  54.     
  55. }