<?php
declare(strict_types=1);
namespace App\Controller;
use App\Entity\Contact;
use App\Entity\Post;
use App\Form\ContactType;
use App\Repository\CategoryRepository;
use App\Repository\FaqRepository;
use App\Repository\LanguageRepository;
use App\Repository\MediaRepository;
use App\Repository\PostRepository;
use App\Repository\PriceRepository;
use App\Service\MailerService;
use App\Service\TravelProgram;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Constraints\Json;
use Symfony\Contracts\Translation\TranslatorInterface;
class HomeController extends AbstractController
{
/**
* @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
*/
#[Route('/', name: 'home')]
public function index(TravelProgram $travelProgram, PostRepository $postRepository): Response
{
$slides = $postRepository->findAllByType('Slide');
$programs = $travelProgram->getProgram();
$aboutUs = $postRepository->findOneByTitle('TLDI Logistique Services');
return $this->render('home/index.html.twig', [
'programs'=>$programs,
'aboutUs'=>$aboutUs,
'slides'=>$slides
]);
}
#[Route('tldi-post/{slug}', name: 'post_details', methods: ['GET'])]
public function details(Post $post,PostRepository $postRepository, Request $request): Response
{
return $this->render('home/post.html.twig', [
'post' => $post,
]);
}
#[Route('/contact', name: 'contact')]
public function contact(Request $request): Response
{
$contact = new Contact();
$form = $this->createForm(ContactType::class, $contact);
$form->handleRequest($request);
return $this->render('home/contact-form.html.twig',[
'form' => $form->createView()
]);
}
#[Route('tldi-service/{slug}', name: 'service_details', methods: ['GET'])]
public function services(Post $post,PostRepository $postRepository, Request $request): Response
{
return $this->render('home/service.html.twig', [
'post' => $post,
]);
}
#[Route('tldi-tarifs/{slug}', name: 'price', methods: ['GET'])]
public function price(Post $post,PostRepository $postRepository,CategoryRepository $categoryRepository, PriceRepository $priceRepository): Response
{
$categoryPrice = $categoryRepository->findOneBy(['slug' =>$post->getSlug()]);
$prices = $priceRepository->findByCategory(['category'=>$categoryPrice->getId()]);
return $this->render('home/price.html.twig', [
'post' => $post,
'categoryPrice' => $categoryPrice,
'prices' => $prices,
]);
}
#[Route('tldi-faq/{slug}', name: 'faq', methods: ['GET'])]
public function faq(Post $post,PostRepository $postRepository, FaqRepository $faqRepository): Response
{
$faqs = $faqRepository->findBy(['is_active' =>true]);
return $this->render('home/faq.html.twig', [
'post' => $post,
'faqs' => $faqs,
]);
}
#[Route('tldi-nos-tarifs/{slug}', name: 'tarifs', methods: ['GET'])]
public function nostarifs(Post $post,PriceRepository $priceRepository): Response
{
//$category = $categoryRepository->findOneBy(['name' =>'Nos tarifs']);
//$prices = $priceRepository->findByCategory(['category'=>$category->getId()]);
return $this->render('home/tarifs.html.twig', [
'post' => $post,
// 'faqs' => $faqs,
]);
}
}