src/Controller/UserProjects/MyUserProjectsController.php line 23

  1. <?php
  2. namespace App\Controller\UserProjects;
  3. use App\Entity\UserProjets;
  4. use App\Entity\Commentaires;
  5. use App\Form\CommentairesType;
  6. use App\Form\UserProjetsType;
  7. use App\Repository\ProjetsRepository;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use App\Repository\UserProjetsRepository;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. use Symfony\Component\Security\Core\User\UserInterface;
  14. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  15. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  16. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  17. class MyUserProjectsController extends AbstractController
  18. {
  19.   #[Route('/mesprojets'name'app_my_user_projects'methods: ['GET'])]
  20.   public function index(UserProjetsRepository $userProjetsRepository): Response
  21.   {
  22.     $user $this->getUser();
  23.     $projects $userProjetsRepository->findBy(['user' => $user]);
  24.     //IF NOT LOGIN
  25.     if (!$user) {
  26.       return $this->redirectToRoute('app_login');
  27.     }
  28.     return $this->render('user_projets/my_project.html.twig', [
  29.       'user_projects' => $projects,
  30.     ]);
  31.   }
  32. }