src/Controller/DefaultController.php line 80

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Atouts;
  4. use App\Entity\Banner;
  5. use App\Entity\Continent;
  6. use App\Entity\Destination;
  7. use App\Entity\Flight;
  8. use App\Entity\Formule;
  9. use App\Entity\HebergemntOffer;
  10. use App\Entity\Highlight;
  11. use App\Entity\Included;
  12. use App\Entity\Informations;
  13. use App\Entity\Itinerary;
  14. use App\Entity\ItineraryPic;
  15. use App\Entity\Offer;
  16. use App\Entity\OfferHebergement;
  17. use App\Entity\OfferInfo;
  18. use App\Entity\TypeVoyage;
  19. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  20. use Symfony\Component\HttpFoundation\Response;
  21. use Symfony\Component\Routing\Annotation\Route;
  22. use Symfony\Component\HttpFoundation\Request;
  23. class DefaultController extends AbstractController
  24. {
  25.     /**
  26.      * @Route("/", name="app")
  27.      */
  28.     public function index()
  29.     {
  30.         $em $this->getDoctrine()->getManager();
  31.         $offEscapade $em->getRepository(Offer::class)->findBy(['type'=>1]);
  32.         $offCircuit $em->getRepository(Offer::class)->findBy(['type'=>2]);
  33.         $ourOffer $em->getRepository(Offer::class)->findBy(['OurOffer'=>1]);
  34.         $infos $em->getRepository(Informations::class)->findOneBy(['id'=>1]);   
  35.         $continents $em->getRepository(Continent::class)->findAll();
  36.         $atouts $em->getRepository(Atouts::class)->findAll();
  37.         $banner $em->getRepository(Banner::class)->findOneBy(['page'=>"contact"]); 
  38.         //dd($atouts); 
  39.         return $this->render('default/index.html.twig',[
  40.             'offEscapade'=>$offEscapade,
  41.             'offCircuit'=>$offCircuit,
  42.             'ourOffer'=>$ourOffer,
  43.             'continents'=>$continents,
  44.             'infos'=>$infos,
  45.             'atouts'=>$atouts,
  46.             'banner'=>$banner
  47.         ]);
  48.     }
  49.     /**
  50.     * @Route("/search", name="search", methods={"GET"})
  51.     */
  52.     public function search(Request $request)
  53.     {
  54.         $em $this->getDoctrine()->getManager();
  55.     $q trim($request->query->get('q'''));
  56.     $results = [];
  57.     if ($q !== '') {
  58.         $results $em->getRepository(Offer::class)->searchOffers($q);
  59.     }
  60.     //dd($results);
  61.     return $this->render('default/search.html.twig', [
  62.         'query'   => $q,
  63.         'results' => $results
  64.     ]);
  65.     }
  66.      /**
  67.      * @Route("/oo", name="footer")
  68.      */
  69.     public function footer()
  70.     {
  71.         $em $this->getDoctrine()->getManager();
  72.         $infos $em->getRepository(Informations::class)->findOneBy(['id'=>1]);   
  73.         return $this->render('default/footer.html.twig',['infos'=>$infos]);
  74.     }
  75.     /**
  76.      * @Route("/o-escapade", name="o.escapade")
  77.      */
  78.     public function escapade()
  79.     {
  80.         $em $this->getDoctrine()->getManager();
  81.         $offer $em->getRepository(TypeVoyage::class)->findBy(['type'=>1]);
  82.         $offers $em->getRepository(Offer::class)->findBy(['type'=>1]);
  83.         return $this->render('default/escapade.html.twig',
  84.         ['offers'=>$offers,
  85.          'offer'=>$offer,
  86.         ]);
  87.     }
  88.      /**
  89.      * @Route("/continent/{slug}", name="o.continent")
  90.      */
  91.     public function continent($slug)
  92.     {
  93.         $em $this->getDoctrine()->getManager();
  94.         $continent $em->getRepository(Continent::class)->findOneBy(['slug'=>$slug]);
  95.         $offers $em->getRepository(Offer::class)->findBy(['continent'=>$continent]);
  96.         return $this->render('default/continent.html.twig',
  97.         ['offers'=>$offers,
  98.          'continent'=>$continent,
  99.         ]);
  100.     }
  101.     /**
  102.      * @Route("/o-escapade/destination/{slug}", name="o.escapade.destination")
  103.      */
  104.     public function escapadeDestination($slug)
  105.     {
  106.         $em $this->getDoctrine()->getManager();
  107.         $destination $em->getRepository(Destination::class)->findOneBy(['slug'=>$slug]);
  108.         $offer $em->getRepository(Offer::class)->findOneBy(['destination'=>$destination->getId()]);
  109.         $offerHebergement $em->getRepository(OfferHebergement::class)->findBy(['offer'=>$offer->getId()]);
  110.         $formules $em->getRepository(Formule::class)->findBy(['offer'=>$offer->getId()]); ;
  111.        
  112.     
  113.         return $this->render('default/escapade-destination.html.twig',
  114.         ['destination'=>$destination,
  115.         'offerHebergement'=>$offerHebergement,
  116.         'formules'=>$formules,
  117.         'offer'=>$offer]);
  118.     }
  119.     /**
  120.      * @Route("/o-escapade", name="o.escapade")
  121.      * @Route("/o-circuit", name="o.circuit")
  122.      * @Route("/o-roadtrip", name="o.roadtrip")
  123.      * @Route("/o-croisiere", name="o.croisiere")
  124.      */
  125.     public function Ooffers(Request $request)
  126.     {   
  127.         $em $this->getDoctrine()->getManager();
  128.         $routeName $request->attributes->get('_route');
  129.          if($routeName == 'o.escapade'){
  130.         $typeOffer $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>1]);
  131.         $offers $em->getRepository(Offer::class)->findBy(['type'=>1]);
  132.         }
  133.         if($routeName == 'o.circuit'){
  134.         $typeOffer $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>2]);
  135.         $offers $em->getRepository(Offer::class)->findBy(['type'=>2]);
  136.         }
  137.          if($routeName == 'o.roadtrip'){
  138.         $typeOffer $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>3]);
  139.         $offers $em->getRepository(Offer::class)->findBy(['type'=>3]);
  140.          }
  141.         if($routeName == 'o.croisiere'){
  142.         $typeOffer $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>4]);
  143.         $offers $em->getRepository(Offer::class)->findBy(['type'=>4]);
  144.          }
  145.         return $this->render('default/offers.html.twig', ['offers'=>$offers,'typeOffer'=> $typeOffer]);
  146.     }
  147.     
  148.     /**
  149.      * @Route("/o-circuit/destination-ex", name="o.circuit.destination-ex")
  150.      */
  151.     public function circuitDestinationEx()
  152.     {
  153.         $em $this->getDoctrine()->getManager();
  154.         return $this->render('default/circuit-destination-ex.html.twig');
  155.     }
  156.       /**
  157.      * @Route("/o-road/destination-ex", name="o.road.destination-ex")
  158.      */
  159.     public function roadtDestinationEx()
  160.     {
  161.         $em $this->getDoctrine()->getManager();
  162.         return $this->render('default/roadtrip-destination.html.twig');
  163.     }
  164.     /**
  165.      * @Route("/o-croisiere/destination-ex", name="o.ccroisiere.destination")
  166.      */
  167.     public function oCroisiere()
  168.     {
  169.         $em $this->getDoctrine()->getManager();
  170.         $id =3;
  171.         $offer $em->getRepository(Offer::class)->findOneBy(['id'=>$id]);
  172.         return $this->render('default/croisiere-destination.html.twig',
  173.         ['offer'=>$offer]);
  174.     }
  175.     /**
  176.      * @Route("/o-circuit/{slug}", name="o.circuit.destination")
  177.      * @Route("/o-roadtrip/{slug}", name="o.roadtrip.destination")
  178.      * @Route("/o-croisiere/{slug}", name="o.croisiere.destination")
  179.      */
  180.     public function oOffer(Request $request$slug)
  181.     {
  182.         $em $this->getDoctrine()->getManager();
  183.         $routeName $request->attributes->get('_route');
  184.         $offer $em->getRepository(Offer::class)->findOneBy(['slug'=>$slug]);
  185.         $highlight =  $em->getRepository(Highlight::class)->findBy(['offer'=>$offer]);
  186.         $itinerary $em->getRepository(Itinerary::class)->findBy(['offer'=>$offer]);
  187.         $photoItinerary $em->getRepository(ItineraryPic::class)->findBy(['Offer'=>$offer]);
  188.         $hebergementOffer $em->getRepository(HebergemntOffer::class)->findBy(['offer'=>$offer]);
  189.         $flight $em->getRepository(Flight::class)->findBy(['offer'=>$offer]) ;
  190.         $infos $em->getRepository(OfferInfo::class)->findBy(['offer'=>$offer]) ; 
  191.         $included $em->getRepository(Included::class)->findBy(['Offer'=>$offer]) ;
  192.           $routeName $request->attributes->get('_route');
  193.         if($routeName == 'o.circuit.destination'){
  194.         
  195.         return $this->render('default/circuit-destination.html.twig',
  196.          ['offer'=>$offer
  197.         'highlight'=>$highlight,
  198.         'photoItinerary'=>$photoItinerary,
  199.         'hebergementOffer'=>$hebergementOffer,
  200.         'included'=>$included,
  201.         'flight'=>$flight,
  202.         'infos'=>$infos,
  203.         'itinerary'=>$itinerary]);
  204.         }
  205.           if($routeName == 'o.roadtrip.destination'){
  206.         
  207.         return $this->render('default/roadtrip-destination.html.twig',
  208.         ['offer'=>$offer
  209.         'highlight'=>$highlight,
  210.         'flight'=>$flight,
  211.         'photoItinerary'=>$photoItinerary,
  212.         'hebergementOffer'=>$hebergementOffer,
  213.         'included'=>$included,
  214.         'infos'=>$infos,
  215.         'itinerary'=>$itinerary]);
  216.         }
  217.           if($routeName == 'o.croisiere.destination'){
  218.         
  219.         return $this->render('default/croisiere-destination.html.twig',
  220.         ['offer'=>$offer
  221.         'highlight'=>$highlight,
  222.         'flight'=>$flight,
  223.         'photoItinerary'=>$photoItinerary,
  224.         'hebergementOffer'=>$hebergementOffer,
  225.         'included'=>$included,
  226.         'infos'=>$infos,
  227.         'itinerary'=>$itinerary]);
  228.         }
  229.     }
  230.      /**
  231.      * @Route("/o-contact", name="o.contact")
  232.      * @Route("/demande-de-devis", name="o.devis")
  233.      */
  234.     public function contact(Request $request)
  235.     {
  236.         $em $this->getDoctrine()->getManager();
  237.         $routeName $request->attributes->get('_route');
  238.         if($routeName == 'o.contact'){
  239.           $em $this->getDoctrine()->getManager();
  240.           $infos $em->getRepository(Informations::class)->findOneBy(['id'=>1]);
  241.           $banner $em->getRepository(Banner::class)->findOneBy(['page'=>"contact"]); 
  242.         
  243.         return $this->render('default/contact.html.twig',['infos'=>$infos'banner'=>$banner]);
  244.         }
  245.          $routeName $request->attributes->get('_route');
  246.          if($routeName == 'o.devis'){
  247.             $typeSejour $em->getRepository(TypeVoyage::class)->findAll();
  248.             $banner $em->getRepository(Banner::class)->findOneBy(['page'=>"devis"]);
  249.          return $this->render('default/devis.html.twig',['typeSejour'=>$typeSejour,'banner'=>$banner]);
  250.         }
  251.     }
  252. }