src/Controller/FrontEnd/HomeController.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Controller\FrontEnd;
  3. use App\classe\Search;
  4. use App\Form\SearchType;
  5. use App\Repository\Admin\PropertyRepository;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class HomeController extends AbstractController
  11. {
  12.     #[Route('/'name'frontend_home')]
  13.     public function index(PropertyRepository $repositoryRequest $request): Response
  14.     {
  15.         $property $repository->findBy(array(),orderBy: ["createdAt"=>"DESC"], limit);
  16.         $search = new Search();
  17.         $form $this->createForm(SearchType::class, $search);
  18.         $form->handleRequest($request);
  19.         if ($form->isSubmitted() && $form->isValid()){
  20.             $property $property $repository->findWidthSearch($search);
  21.         }
  22.         return $this->render('front_end/home/index.html.twig', [
  23.             'controller_name' => 'Home',
  24.             'property'=>$property,
  25.             'propertyTosel'=>$repository->findBy(["isToSale"=>1],orderBy: ["createdAt"=>"DESC"],limit6),
  26.              'propertyTorent'=>$repository->findBy(["isRent"=>1],orderBy: ["createdAt"=>"DESC"], limit6),
  27.             'Form'=>$form->createView()
  28.         ]);
  29.     }
  30. }