src/Controller/HomeController.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Project;
  4. use App\Entity\Task;
  5. use App\Entity\User;
  6. use App\Entity\UserPro;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class HomeController extends AbstractController
  11. {
  12.     #[Route('/'name'home')]
  13.     public function index(): Response
  14.     {
  15.         /** @var User $user */
  16.         $user $this->getUser();
  17.         $myTasks $user->getTasksAssigne()->filter(function (Task  $task){
  18.             return $task->getStatus()!= Task::STATUS_DONE;
  19.         });
  20.         $projets null;
  21.         $tmanull;
  22.         if($user->hasRole(User::ROLE_CLIENT)){
  23.             $projets $user->getUserPros();
  24.             /** @var Project $firstProject */
  25.             $firstProject $user->getUserPros()->first()->getProject();
  26.             $tma $firstProject->getTMAs()->last();
  27.         }
  28.         return $this->render('home/index.html.twig', [
  29.             'myTasks' =>$myTasks,
  30.             'myProject'=> $projets && $projets->first() ? $projets->first()->getProject() : null,
  31.             'tma' => $tma
  32.         ]);
  33.     }
  34. }