<?php
namespace App\Controller;
use App\Entity\Continent;
use App\Entity\Destination;
use App\Entity\Flight;
use App\Entity\Formule;
use App\Entity\HebergemntOffer;
use App\Entity\Highlight;
use App\Entity\Included;
use App\Entity\Itinerary;
use App\Entity\ItineraryPic;
use App\Entity\Offer;
use App\Entity\OfferHebergement;
use App\Entity\OfferInfo;
use App\Entity\TypeVoyage;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends AbstractController
{
/**
* @Route("/", name="app")
*/
public function index()
{
$em = $this->getDoctrine()->getManager();
$offEscapade = $em->getRepository(Offer::class)->findBy(['type'=>1]);
$offCircuit = $em->getRepository(Offer::class)->findBy(['type'=>2]);
$ourOffer = $em->getRepository(Offer::class)->findBy(['OurOffer'=>1]);
$continents = $em->getRepository(Continent::class)->findAll();
return $this->render('default/index.html.twig',[
'offEscapade'=>$offEscapade,
'offCircuit'=>$offCircuit,
'ourOffer'=>$ourOffer,
'continents'=>$continents
]);
}
/**
* @Route("/oo", name="oo")
*/
public function oo()
{
return $this->render('default/maintenance.html.twig');
}
/**
* @Route("/o-escapade", name="o.escapade")
*/
public function escapade()
{
$em = $this->getDoctrine()->getManager();
$offer = $em->getRepository(TypeVoyage::class)->findBy(['type'=>1]);
$offers = $em->getRepository(Offer::class)->findBy(['type'=>1]);
return $this->render('default/escapade.html.twig',
['offers'=>$offers,
'offer'=>$offer,
]);
}
/**
* @Route("/continent/{slug}", name="o.continent")
*/
public function continent($slug)
{
$em = $this->getDoctrine()->getManager();
$continent = $em->getRepository(Continent::class)->findOneBy(['slug'=>$slug]);
$offers = $em->getRepository(Offer::class)->findBy(['continent'=>$continent]);
return $this->render('default/continent.html.twig',
['offers'=>$offers,
'continent'=>$continent,
]);
}
/**
* @Route("/o-escapade/destination/{slug}", name="o.escapade.destination")
*/
public function escapadeDestination($slug)
{
$em = $this->getDoctrine()->getManager();
$destination = $em->getRepository(Destination::class)->findOneBy(['slug'=>$slug]);
$offer = $em->getRepository(Offer::class)->findOneBy(['destination'=>$destination->getId()]);
$offerHebergement = $em->getRepository(OfferHebergement::class)->findBy(['offer'=>$offer->getId()]);
$formules = $em->getRepository(Formule::class)->findBy(['offer'=>$offer->getId()]); ;
return $this->render('default/escapade-destination.html.twig',
['destination'=>$destination,
'offerHebergement'=>$offerHebergement,
'formules'=>$formules,
'offer'=>$offer]);
}
/**
* @Route("/o-escapade", name="o.escapade")
* @Route("/o-circuit", name="o.circuit")
* @Route("/o-roadtrip", name="o.roadtrip")
* @Route("/o-croisiere", name="o.croisiere")
*/
public function Ooffers(Request $request)
{
$em = $this->getDoctrine()->getManager();
$routeName = $request->attributes->get('_route');
if($routeName == 'o.escapade'){
$typeOffer = $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>1]);
$offers = $em->getRepository(Offer::class)->findBy(['type'=>1]);
}
if($routeName == 'o.circuit'){
$typeOffer = $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>2]);
$offers = $em->getRepository(Offer::class)->findBy(['type'=>2]);
}
if($routeName == 'o.roadtrip'){
$typeOffer = $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>3]);
$offers = $em->getRepository(Offer::class)->findBy(['type'=>3]);
}
if($routeName == 'o.croisiere'){
$typeOffer = $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>4]);
$offers = $em->getRepository(Offer::class)->findBy(['type'=>4]);
}
return $this->render('default/offers.html.twig', ['offers'=>$offers,'typeOffer'=> $typeOffer]);
}
/**
* @Route("/o-circuit/destination-ex", name="o.circuit.destination-ex")
*/
public function circuitDestinationEx()
{
$em = $this->getDoctrine()->getManager();
return $this->render('default/circuit-destination-ex.html.twig');
}
/**
* @Route("/o-road/destination-ex", name="o.road.destination-ex")
*/
public function roadtDestinationEx()
{
$em = $this->getDoctrine()->getManager();
return $this->render('default/roadtrip-destination.html.twig');
}
/**
* @Route("/o-croisiere/destination-ex", name="o.ccroisiere.destination")
*/
public function oCroisiere()
{
$em = $this->getDoctrine()->getManager();
$id =3;
$offer = $em->getRepository(Offer::class)->findOneBy(['id'=>$id]);
return $this->render('default/croisiere-destination.html.twig',
['offer'=>$offer]);
}
/**
* @Route("/o-circuit/{slug}", name="o.circuit.destination")
* @Route("/o-roadtrip/{slug}", name="o.roadtrip.destination")
* @Route("/o-croisiere/{slug}", name="o.croisiere.destination")
*/
public function oOffer(Request $request, $slug)
{
$em = $this->getDoctrine()->getManager();
$routeName = $request->attributes->get('_route');
$offer = $em->getRepository(Offer::class)->findOneBy(['slug'=>$slug]);
$highlight = $em->getRepository(Highlight::class)->findBy(['offer'=>$offer]);
$itinerary = $em->getRepository(Itinerary::class)->findBy(['offer'=>$offer]);
$photoItinerary = $em->getRepository(ItineraryPic::class)->findBy(['Offer'=>$offer]);
$hebergementOffer = $em->getRepository(HebergemntOffer::class)->findBy(['offer'=>$offer]);
$flight = $em->getRepository(Flight::class)->findBy(['offer'=>$offer]) ;
$infos = $em->getRepository(OfferInfo::class)->findBy(['offer'=>$offer]) ;
$included = $em->getRepository(Included::class)->findBy(['Offer'=>$offer]) ;
$routeName = $request->attributes->get('_route');
if($routeName == 'o.circuit.destination'){
return $this->render('default/circuit-destination.html.twig',
['offer'=>$offer,
'highlight'=>$highlight,
'photoItinerary'=>$photoItinerary,
'hebergementOffer'=>$hebergementOffer,
'included'=>$included,
'flight'=>$flight,
'infos'=>$infos,
'itinerary'=>$itinerary]);
}
if($routeName == 'o.roadtrip.destination'){
return $this->render('default/roadtrip-destination.html.twig',
['offer'=>$offer,
'highlight'=>$highlight,
'flight'=>$flight,
'photoItinerary'=>$photoItinerary,
'hebergementOffer'=>$hebergementOffer,
'included'=>$included,
'infos'=>$infos,
'itinerary'=>$itinerary]);
}
if($routeName == 'o.croisiere.destination'){
return $this->render('default/croisiere-destination.html.twig',
['offer'=>$offer,
'highlight'=>$highlight,
'flight'=>$flight,
'photoItinerary'=>$photoItinerary,
'hebergementOffer'=>$hebergementOffer,
'included'=>$included,
'infos'=>$infos,
'itinerary'=>$itinerary]);
}
}
/**
* @Route("/o-contact", name="o.contact")
* @Route("/demande-de-devis", name="o.devis")
*/
public function contact(Request $request)
{
$em = $this->getDoctrine()->getManager();
$routeName = $request->attributes->get('_route');
if($routeName == 'o.contact'){
return $this->render('default/contact.html.twig');
}
$routeName = $request->attributes->get('_route');
if($routeName == 'o.devis'){
$typeSejour = $em->getRepository(TypeVoyage::class)->findAll();
return $this->render('default/devis.html.twig',['typeSejour'=>$typeSejour]);
}
}
}