src/Realty/Controller/LayoutController.php line 22

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Realty\Controller;
  3. use App\Base\Controller\BaseController;
  4. use App\Leads\Form\ApartmentRecallType;
  5. use App\Leads\Form\LayoutRecallType;
  6. use App\Realty\Entity\Apartment;
  7. use App\Realty\Entity\FloorModel;
  8. use App\Realty\Entity\Layout;
  9. use App\Realty\Repository\ApartmentRepository;
  10. use App\Realty\Repository\LayoutRepository;
  11. use Doctrine\Persistence\ManagerRegistry;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. use function Doctrine\ORM\QueryBuilder;
  16. class LayoutController extends BaseController
  17. {
  18.     #[Route(path'/realty/layout_modal/{id}'name'realty:layout_modal')]
  19.     public function layoutModal(
  20.         Request $request,
  21.         Layout $layout
  22.     ): Response {
  23.         $form $this->createForm(LayoutRecallType::class);
  24.         $form->get('link')->setData($request->getUri());
  25.         return $this->render('pages/modal/realty/_layout-modal.html.twig', [
  26.             'layout' => $layout,
  27.             'idType' => 'layout',
  28.             'form' => $form->createView(),
  29.         ]);
  30.     }
  31.     #[Route(path'/realty/apartment_modal/{id}'name'realty:apartment_modal')]
  32.     public function apartmentModal(
  33.         Request $request,
  34.         Apartment $apartment
  35.     ): Response {
  36.         $form $this->createForm(ApartmentRecallType::class);
  37.         $form->get('link')->setData($request->getUri());
  38.         return $this->render('pages/modal/realty/_apartment-modal.html.twig', [
  39.             'apartment' => $apartment,
  40.             'idType' => 'apartment',
  41.             'form' => $form->createView(),
  42.         ]);
  43.     }
  44.     #[Route(path'/realty/outer_modal/{outerKey}'name'realty:outer_modal')]
  45.     public function outerModal(
  46.         Request $request,
  47.         Apartment $apartment
  48.     ): Response {
  49.         return $this->apartmentModal($request$apartment);
  50.     }
  51.     #[Route(path'/realty/floor_modal/{id}'name'realty:floor_modal')]
  52.     public function floorModal(
  53.         FloorModel $floor,
  54.     ): Response {
  55.         return $this->render('_parts/genplan/_floor.html.twig', [
  56.             'floor' => $floor,
  57.         ]);
  58.     }
  59.     #[Route(path'/realty/floor_genplan/{id}'name'realty:floor_genplan')]
  60.     public function floorGenplan(
  61.         FloorModel $floor,
  62.     ): Response {
  63.         return $this->render('_parts/genplan/_floor-genplan.html.twig', [
  64.             'floor' => $floor,
  65.         ]);
  66.     }
  67.     #[Route(path'/share/layout/{id}'name'realty:share_layout')]
  68.     public function shareLayout(
  69.         Request $request,
  70.         int $id,
  71.         LayoutRepository $layoutRepository
  72.     ): Response {
  73.         $qb $layoutRepository->createQueryBuilder('layout');
  74.         $layout $qb
  75.             ->join('layout.apartments''apartments')
  76.             ->where("layout.id = {$id}")
  77.             ->andWhere('apartments.hidden = false')
  78.             ->getQuery()
  79.             ->getResult();
  80.         if (!$layout) {
  81.             return $this->json(['error' => "layout with {$id} could not found"], 500);
  82.         }
  83.         return $this->json([
  84.             'success' => true
  85.         ]);
  86.     }
  87.     #[Route(path'/share/apartment/{id}'name'realty:share_apartment')]
  88.     public function shareApartment(
  89.         Request $request,
  90.         int $id,
  91.         ApartmentRepository $apartmentRepository
  92.     ): Response {
  93.         $apartment $apartmentRepository->findOneBy(['id' => $id'hidden' => false]);
  94.         if (!$apartment) {
  95.             return $this->json(['error' => "apartment with {$id} could not found"], 500);
  96.         }
  97.         return $this->json([
  98.             'success' => true
  99.         ]);
  100.     }
  101.     #[Route(path'/share/outer/{outerId}'name'realty:share_outer')]
  102.     public function shareOuter(
  103.         Request $request,
  104.         int $outerId,
  105.         ApartmentRepository $apartmentRepository
  106.     ): Response {
  107.         $apartment $apartmentRepository->findOneBy(['outerKey' => $outerId'hidden' => false]);
  108.         if (!$apartment) {
  109.             return $this->json(['error' => "apartment with outer {$outerId} could not found"], 500);
  110.         }
  111.         return $this->json([
  112.             'success' => true
  113.         ]);
  114.     }
  115. }