<?php
namespace App\Controller\Front;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use App\Entity\Estate;
use App\Entity\Review;
use App\Entity\Config;
class HomeController extends AbstractController
{
public function __construct(ParameterBagInterface $params)
{
$this->menu = $params->get('main_menu');
$this->footer_links = $params->get('footer_links');
}
/**
* @Route("/", name="homepage")
*/
public function index(): Response
{
// if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1', '86.246.10.89')))
// {
// return $this->render('front/home/on_work.html.twig');
// }
$last_estates = $this->getDoctrine()
->getRepository(Estate::class)
->findLast();
return $this->render('front/home/index.html.twig', [
'estates' => $last_estates,
]);
}
/**
* include header
*/
public function menu($current_route): Response
{
$request = Request::createFromGlobals();
$menu = [];
foreach( $this->menu as $route =>$title){
$class = $route == $current_route ? 'active' : '';
$menu[$route] = ['title' => $title, 'class' => $class];
}
$sous_menus["acheter"] = [
"Maison" => ["key" => "type", "value" => "maison/villa"],
"Appartement" => ["key" => "type", "value" => "appartement"],
"Terrain" => ["key" => "type", "value" => "terrain"],
"Neuf" => ["key" => "neuf", "value" => 1],
"Nue-propriété" => ["key" => "nue_propriete", "value" => 1],
"Autres" => ["key" => "autres", "value" => 1]
];
foreach( $sous_menus as $name => $sous_menu){
foreach( $sous_menu as $label => $s_menu ){
$get_value = $request->query->get($s_menu['key']);
$class = $get_value == $s_menu['value'] ? 'active' : '';
$sous_menus[$name][$label]['class'] = $class;
}
}
return $this->render('front/_common/_menu.html.twig', [
'menu' => $menu,
'sous_menus' => $sous_menus,
'current_route' => $current_route
]);
}
/**
* include home, estimation
*/
public function osKpis($rating_limit = 80, $with_os = false): Response
{
$rating_os = $this->getDoctrine()->getRepository(Config::class)->findValue("rating_os");
$satisfaction_os = $this->getDoctrine()->getRepository(Config::class)->findValue("satisfaction_os");
$total_reviews = $this->getDoctrine()->getRepository(Config::class)->findValue("nb_reviews_os");
return $this->render('front/_common/_os_kpis.html.twig', [
'rating_os' => $rating_os,
'satisfaction_os' => $satisfaction_os,
'total_reviews' => $total_reviews,
]);
}
/**
* include home, estimation
*/
public function testimonies($rating_limit = 80, $with_os = false): Response
{
$reviews = $this->getDoctrine()->getRepository(Review::class)->findForHome($rating_limit);
return $this->render('front/_common/_testimonies.html.twig', [
'reviews' => $reviews,
]);
}
/**
* include footer
*/
public function footerLinks(): Response
{
return $this->render('front/_common/_footer_links.html.twig', [
'footer_links' => $this->footer_links,
]);
}
/**
* include footer accueil/vendre/estimer
*/
public function lastSales(): Response
{
$estates = $this->getDoctrine()
->getRepository(Estate::class)
->findLastSales(2);
return $this->render('front/_common/_lastsales.html.twig', [
'estates' => $estates,
]);
}
public function lastEstates(): Response
{
// $last_news = $this->getDoctrine()
// ->getRepository(Estate::class)
// ->findLastNews();
$last_sales = $this->getDoctrine()
->getRepository(Estate::class)
->findLastSales(4);
return $this->render('front/_common/_lastestates.html.twig', [
// 'last_news' => $last_news,
'last_sales' => $last_sales,
]);
}
public function partenaires(): Response
{
$partenaires = [
// "https://www.meilleursagents.com/agence-immobiliere/agence-sublimons-transactions-65023/" => "MeilleurAgents.png",
"https://www.leboncoin.fr/boutique/51442" => "LeBonCoin.png",
"https://www.seloger.com/professionnels/agences-immobilieres/vannes-56000/agence-30199/#?avisImmo=true" => "SeLoger.png",
"https://www.ouestfrance-immo.com/annuaire-immobilier/agence-immobiliere/sublimons-l-agence-immobiliere-56-13978.htm" => "OF2.png",
"https://www.paruvendu.fr/immobilier/pro/sublimons-vannes-56-52492/" => "ParuVendu.png",
"https://proprietes.lefigaro.fr/agences/vannes-morbihan-bretagne-france/572682424/" => "LeFigaro.png",
"https://www.fnaim.fr/agence-immobiliere/912380/43-vannes-sublimons-transactions.htm" => "Fnaim.png",
// "https://www.oscars-morbihan.fr/candidats-2014/sublimons-service-a-la-personne-56011-vannes" => "Pub1.png",
"https://www.bureauxlocaux.com/agence/sublimons-3243" => "logo_bureaux_locaux.png",
"https://www.bienici.com/annonces-sublimons-2" => "logo_bien_ici.png",
"https://www.jamesedition.com/fr/offices/sublimons-l-agence-immobiliere-113080" => "logo_james_edition.png",
// "https://www.constructions-du-belon.com/" => "Constructions-du-Belon.png",
"https://sublimons-commerces-immopro.octissimo.com/" => "Cession_PME.png",
"" => "septeo.png",
];
return $this->render('front/_common/_marquee.html.twig', [
'partenaires' => $partenaires,
'speed' => 10,
'displayed' => [
'xs' => 3,
'sm' => 4,
'md' => 5,
'lg' => 6,
'xl' => 7,
'xxl' => 8,
]
]);
}
}