src/Controller/Front/HomeController.php line 41

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use Symfony\Component\HttpFoundation\Request;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  8. use App\Entity\Estate;
  9. use App\Entity\Review;
  10. use App\Entity\Config;
  11. class HomeController  extends AbstractController
  12. {
  13.     public function __construct(ParameterBagInterface $params)
  14.     {
  15.         $this->menu = $params->get('main_menu');
  16.         $this->footer_links = $params->get('footer_links');
  17.     }
  18.     
  19.     /**
  20.      * @Route("/", name="homepage")
  21.      */
  22.     public function index(): Response
  23.     {   
  24.         // if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1', '86.246.10.89')))
  25.         // {
  26.         //     return $this->render('front/home/on_work.html.twig');
  27.         // }
  28.         $last_estates =  $this->getDoctrine()
  29.         ->getRepository(Estate::class)
  30.         ->findLast();
  31.         return $this->render('front/home/index.html.twig', [
  32.             'estates' => $last_estates,
  33.         ]);
  34.     
  35.     }
  36.     /** 
  37.      * include header
  38.      */
  39.     public function menu($current_route): Response
  40.     {   
  41.         $request = Request::createFromGlobals();    
  42.         $menu = [];  
  43.         foreach( $this->menu as  $route =>$title){
  44.             $class = $route == $current_route ? 'active' : '';
  45.             $menu[$route] = ['title' => $title, 'class' => $class];
  46.         }
  47.         $sous_menus["acheter"] = [
  48.             "Maison" => ["key" => "type", "value" => "maison/villa"],
  49.             "Appartement" => ["key" => "type", "value" => "appartement"],
  50.             "Terrain" => ["key" => "type", "value" => "terrain"], 
  51.             "Neuf" => ["key" => "neuf", "value" => 1], 
  52.             "Nue-propriété" => ["key" => "nue_propriete", "value" => 1],
  53.             "Autres" => ["key" => "autres", "value" => 1]
  54.         ];  
  55.         foreach( $sous_menus as $name => $sous_menu){
  56.             foreach( $sous_menu as $label => $s_menu ){
  57.                 $get_value = $request->query->get($s_menu['key']);
  58.                 $class = $get_value == $s_menu['value'] ? 'active' : '';
  59.                 $sous_menus[$name][$label]['class'] = $class;
  60.             }
  61.         }
  62.         
  63.         return $this->render('front/_common/_menu.html.twig', [
  64.             'menu' => $menu,
  65.             'sous_menus' => $sous_menus,
  66.             'current_route' => $current_route
  67.         ]);
  68.     }
  69.     /**
  70.      * include  home, estimation
  71.      */
  72.     public function osKpis($rating_limit = 80, $with_os = false): Response
  73.     {   
  74.         $rating_os = $this->getDoctrine()->getRepository(Config::class)->findValue("rating_os");
  75.         $satisfaction_os = $this->getDoctrine()->getRepository(Config::class)->findValue("satisfaction_os");
  76.         $total_reviews = $this->getDoctrine()->getRepository(Config::class)->findValue("nb_reviews_os");
  77.         return $this->render('front/_common/_os_kpis.html.twig', [
  78.             'rating_os' =>  $rating_os,
  79.             'satisfaction_os' =>  $satisfaction_os,
  80.             'total_reviews' => $total_reviews,
  81.         ]);
  82.     }
  83.     /**
  84.      * include  home, estimation
  85.      */
  86.     public function testimonies($rating_limit = 80, $with_os = false): Response
  87.     {   
  88.         $reviews = $this->getDoctrine()->getRepository(Review::class)->findForHome($rating_limit);
  89.         return $this->render('front/_common/_testimonies.html.twig', [
  90.             'reviews' =>  $reviews,
  91.         ]);
  92.     }
  93.     /**
  94.      * include  footer
  95.      */
  96.     public function footerLinks(): Response
  97.     {       
  98.         return $this->render('front/_common/_footer_links.html.twig', [
  99.             'footer_links' =>  $this->footer_links,
  100.         ]);
  101.     }
  102.     /**
  103.      * include  footer accueil/vendre/estimer
  104.      */
  105.     public function lastSales(): Response
  106.     {
  107.         $estates =  $this->getDoctrine()
  108.         ->getRepository(Estate::class)
  109.         ->findLastSales(2);
  110.         return $this->render('front/_common/_lastsales.html.twig', [
  111.             'estates' =>  $estates,
  112.         ]);
  113.     }
  114.     public function lastEstates(): Response
  115.     {
  116.         // $last_news =  $this->getDoctrine()
  117.         // ->getRepository(Estate::class)
  118.         // ->findLastNews();
  119.         $last_sales =  $this->getDoctrine()
  120.         ->getRepository(Estate::class)
  121.         ->findLastSales(4);
  122.         return $this->render('front/_common/_lastestates.html.twig', [
  123.             // 'last_news' =>  $last_news,
  124.             'last_sales' =>  $last_sales,
  125.         ]);
  126.     }
  127.     public function partenaires(): Response
  128.     {
  129.         $partenaires = [
  130.             // "https://www.meilleursagents.com/agence-immobiliere/agence-sublimons-transactions-65023/" => "MeilleurAgents.png",
  131.             "https://www.leboncoin.fr/boutique/51442" => "LeBonCoin.png",
  132.             "https://www.seloger.com/professionnels/agences-immobilieres/vannes-56000/agence-30199/#?avisImmo=true" => "SeLoger.png",
  133.             "https://www.ouestfrance-immo.com/annuaire-immobilier/agence-immobiliere/sublimons-l-agence-immobiliere-56-13978.htm" => "OF2.png",
  134.             "https://www.paruvendu.fr/immobilier/pro/sublimons-vannes-56-52492/" => "ParuVendu.png",
  135.             "https://proprietes.lefigaro.fr/agences/vannes-morbihan-bretagne-france/572682424/" => "LeFigaro.png",
  136.             "https://www.fnaim.fr/agence-immobiliere/912380/43-vannes-sublimons-transactions.htm" => "Fnaim.png",
  137.             // "https://www.oscars-morbihan.fr/candidats-2014/sublimons-service-a-la-personne-56011-vannes" => "Pub1.png",
  138.             "https://www.bureauxlocaux.com/agence/sublimons-3243" => "logo_bureaux_locaux.png",
  139.             "https://www.bienici.com/annonces-sublimons-2" => "logo_bien_ici.png",
  140.             "https://www.jamesedition.com/fr/offices/sublimons-l-agence-immobiliere-113080" => "logo_james_edition.png",
  141.             // "https://www.constructions-du-belon.com/" => "Constructions-du-Belon.png",
  142.             "https://sublimons-commerces-immopro.octissimo.com/" => "Cession_PME.png",
  143.             "" => "septeo.png",
  144.         ];  
  145.         return $this->render('front/_common/_marquee.html.twig', [
  146.             'partenaires' => $partenaires,
  147.             'speed' => 10,
  148.             'displayed' => [
  149.                 'xs' => 3,
  150.                 'sm' => 4,
  151.                 'md' => 5,
  152.                 'lg' => 6,
  153.                 'xl' => 7,
  154.                 'xxl' => 8,
  155.             ]
  156.         ]);      
  157.     }
  158. }