<?php
namespace App\Controller\Client\Fr;
use App\Entity\DemandeDeCotation;
use App\Form\DemandeDeCotationType;
use App\Repository\DemandeDeCotationRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class DemandeDeCotationController extends AbstractController
{
/**
* @Route("/demande-de-cotation", name="demande_de_cotation_new", methods={"GET","POST"})
*/
public function new(Request $request): Response
{
$demandeDeCotation = new DemandeDeCotation();
$form = $this->createForm(DemandeDeCotationType::class, $demandeDeCotation);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($demandeDeCotation);
$entityManager->flush();
$this->addFlash('success',"Votre demande de cotation a été transmise avec succès.");
return $this->redirectToRoute('demande_de_cotation_new');
}
return $this->render('client/fr/demande_de_cotation/new.html.twig', [
'demande_de_cotation' => $demandeDeCotation,
'form' => $form->createView(),
]);
}
}