<?php
// src/Controller/LuckyController.php
namespace App\Controller;
use App\Entity\Matchs;
use App\Entity\MatchsUser;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class DefaultController extends AbstractController
{
/**
* @Route("/", name="app_index")
*/
public function index(EntityManagerInterface $em): Response
{
return $this->render('default/index.html.twig', [
// 'matchs' => $matchs
]);
}
/**
* @Route("/home", name="app_home")
*/
public function home(EntityManagerInterface $em): Response
{
$matchs = $em->getRepository(Matchs::class)->findActiveMatchs();
$users = [];
foreach ($matchs as $match) {
foreach ($match->getMatchsUsers() as $key => $matchsUsers) {
/** @var MatchsUser $matchsUsers */
$users[$match->getId()][$key] = $matchsUsers->getUser();
}
}
$endedMatchs = $em->getRepository(Matchs::class)->findEndedMatchs();
// dump($matchs);
// dd($endedMatchs);
return $this->render('home/index.html.twig', [
'matchs' => $matchs,
'endedMatchs' => $endedMatchs,
'users' => $users
]);
}
/**
* @Route("/waiting", name="app_waiting")
*/
public function waiting(EntityManagerInterface $em): Response
{
return $this->render('home/waiting.html.twig');
}
}