src/Controller/HomeController.php line 14

  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Http\Attribute\IsGranted;
  7. #[IsGranted('ROLE_USER')]
  8. class HomeController extends AbstractController
  9. {
  10.     #[Route('/'name'app_home')]
  11.     public function index(): Response
  12.     {
  13.         if($this->getUser()->getParents() != null)
  14.         {
  15.             if(count($this->getUser()->getParents()->getStudents()->getValues()) > 1)
  16.             {
  17.                 return $this->redirectToRoute('app_students_my_childrens');
  18.             }
  19.             return $this->redirectToRoute('app_students_show', ['id' => $this->getUser()->getParents()->getStudents()[0]->getId()]);
  20.         }
  21.         return $this->render('home/index.html.twig', [
  22.             'controller_name' => 'HomeController',
  23.         ]);
  24.     }
  25. }