src/Controller/HomeController.php line 33

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller;
  4. use App\Entity\Contact;
  5. use App\Entity\Post;
  6. use App\Form\ContactType;
  7. use App\Repository\CategoryRepository;
  8. use App\Repository\FaqRepository;
  9. use App\Repository\LanguageRepository;
  10. use App\Repository\MediaRepository;
  11. use App\Repository\PostRepository;
  12. use App\Repository\PriceRepository;
  13. use App\Service\MailerService;
  14. use App\Service\TravelProgram;
  15. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  16. use Symfony\Component\HttpFoundation\Request;
  17. use Symfony\Component\HttpFoundation\Response;
  18. use Symfony\Component\Mailer\MailerInterface;
  19. use Symfony\Component\Mime\Email;
  20. use Symfony\Component\Routing\Annotation\Route;
  21. use Symfony\Component\Validator\Constraints\Json;
  22. use Symfony\Contracts\Translation\TranslatorInterface;
  23. class HomeController extends AbstractController
  24. {
  25.     /**
  26.      * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
  27.      */
  28.     #[Route('/'name'home')]
  29.     public function index(TravelProgram $travelProgramPostRepository $postRepository): Response
  30.     {
  31.       $slides =  $postRepository->findAllByType('Slide');
  32.       $programs $travelProgram->getProgram();
  33.       $aboutUs $postRepository->findOneByTitle('TLDI Logistique Services');
  34.         return $this->render('home/index.html.twig', [
  35.             'programs'=>$programs,
  36.             'aboutUs'=>$aboutUs,
  37.             'slides'=>$slides
  38.         ]);
  39.     }
  40.     #[Route('tldi-post/{slug}'name'post_details'methods: ['GET'])]
  41.     public function details(Post $post,PostRepository $postRepositoryRequest $request): Response
  42.     {
  43.         return $this->render('home/post.html.twig', [
  44.             'post' => $post,
  45.         ]);
  46.     }
  47.     #[Route('/contact'name'contact')]
  48.     public function contact(Request $request): Response
  49.     {
  50.         $contact = new Contact();
  51.         $form $this->createForm(ContactType::class, $contact);
  52.         $form->handleRequest($request);
  53.         return $this->render('home/contact-form.html.twig',[
  54.             'form' => $form->createView()
  55.         ]);
  56.     }
  57.     #[Route('tldi-service/{slug}'name'service_details'methods: ['GET'])]
  58.     public function services(Post $post,PostRepository $postRepositoryRequest $request): Response
  59.     {
  60.         return $this->render('home/service.html.twig', [
  61.             'post' => $post,
  62.         ]);
  63.     }
  64.     #[Route('tldi-tarifs/{slug}'name'price'methods: ['GET'])]
  65.     public function price(Post $post,PostRepository $postRepository,CategoryRepository $categoryRepositoryPriceRepository $priceRepository): Response
  66.     {
  67.         $categoryPrice $categoryRepository->findOneBy(['slug' =>$post->getSlug()]);
  68.         $prices $priceRepository->findByCategory(['category'=>$categoryPrice->getId()]);
  69.         return $this->render('home/price.html.twig', [
  70.             'post' => $post,
  71.             'categoryPrice' => $categoryPrice,
  72.             'prices' => $prices,
  73.         ]);
  74.     }
  75.     #[Route('tldi-faq/{slug}'name'faq'methods: ['GET'])]
  76.     public function faq(Post $post,PostRepository $postRepositoryFaqRepository $faqRepository): Response
  77.     {
  78.         $faqs $faqRepository->findBy(['is_active' =>true]);
  79.         return $this->render('home/faq.html.twig', [
  80.             'post' => $post,
  81.             'faqs' => $faqs,
  82.         ]);
  83.     }
  84.     #[Route('tldi-nos-tarifs/{slug}'name'tarifs'methods: ['GET'])]
  85.     public function nostarifs(Post $post,PriceRepository $priceRepository): Response
  86.     {
  87.         //$category =  $categoryRepository->findOneBy(['name' =>'Nos tarifs']);
  88.         //$prices = $priceRepository->findByCategory(['category'=>$category->getId()]);
  89.         return $this->render('home/tarifs.html.twig', [
  90.             'post' => $post,
  91.            // 'faqs' => $faqs,
  92.         ]);
  93.     }
  94. }