src/Controller/MainPageController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use App\Entity\Room;
  8. use App\Entity\Flat;
  9. class MainPageController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/", name="app_main_page")
  13.      */
  14.     public function index(Request $request): Response
  15.     {
  16.         $locale $request->getLocale();
  17.         //get latest 12 rooms published
  18.         $rooms $this->getDoctrine()->getRepository(Room::class)->findLimitNoUser(0,12);
  19.         //get latest 12 rooms published
  20.         $flats $this->getDoctrine()->getRepository(Flat::class)->findLimitNoUser(0,12);
  21.         
  22.         return $this->render('public/index.html.twig', [
  23.             'lang_locale'=>$locale,
  24.             'rooms'=>$rooms,
  25.             'flats'=>$flats
  26.         ]);
  27.     }
  28.     
  29. }