src/Troika/RealEstateBundle/Model/LotModel.php line 832

Open in your IDE?
  1. <?php
  2. namespace Troika\RealEstateBundle\Model;
  3. use Troika\MainBundle\Entity\Lot;
  4. class LotModel
  5. {
  6.     public function __construct($em$paginator)
  7.     {
  8.         $this->_em $em;
  9.         $this->paginator $paginator;
  10.     }
  11.     protected $_em;
  12.     private function _setQueryCountry($query$country)
  13.     {
  14.         return $query
  15.           ->andWhere('lot.country IN (:country)')
  16.           ->setParameter('country'$country);
  17.     }
  18.     private function _setQueryCountryCity($query$countryCity)
  19.     {
  20.         return $query
  21.           ->andWhere('lot.countryCity IN (:countryCity)')
  22.           ->setParameter('countryCity'$countryCity);
  23.     }
  24.     private function _setQueryDistance($query$min$max)
  25.     {
  26.         if ($max 50) {
  27.             $query
  28.               ->andWhere('lot.mkadDistance <= :distance_max')
  29.               ->setParameter('distance_max'$max);
  30.         }
  31.         if ($min 0) {
  32.             $query
  33.               ->andWhere('lot.mkadDistance >= :distance_min')
  34.               ->setParameter('distance_min'$min);
  35.         }
  36.         return $query;
  37.     }
  38.     private function _setQueryDistrict($query$district)
  39.     {
  40.         return $query
  41.           ->andWhere('lot.district3 IN (:district)')
  42.           ->setParameter('district'$district);
  43.     }
  44.     private function _setQueryHighway($query$highway)
  45.     {
  46.         if ((is_countable($highway) ? count($highway) : 0) > 0) {
  47.             return $query
  48.               ->andWhere('lot.highway IN (:highway)')
  49.               ->setParameter('highway'$highway);
  50.         }
  51.     }
  52.     private function _setQueryHomesteadArea($query$min$max)
  53.     {
  54.         if ($max 150) {
  55.             $query->andWhere('lot.homesteadArea <= :homesteadArea_max')->setParameter('homesteadArea_max'$max);
  56.         }
  57.         if ($min 0) {
  58.             $query->andWhere('lot.homesteadArea >= :homesteadArea_min')->setParameter('homesteadArea_min'$min);
  59.         }
  60.         return $query;
  61.     }
  62.     private function _setQueryPrice($query$min$max)
  63.     {
  64.         if ($max 15000 && $min <= 0) {
  65.             $query
  66.               ->andWhere('lot.dollars <= :price_max')
  67.               ->andWhere('lot.dollars > :m')
  68.               ->setParameter('price_max'$max 1000)
  69.               ->setParameter('m'1);
  70.         }
  71.         if ($min && $max >= 15000) {
  72.             //->andWhere('lot.dollars >= :price_min')
  73.             $query
  74.               ->andWhere(
  75.                 $query->expr()->orX(
  76.                   $query->expr()->gte('lot.dollars'$min 1000)
  77.                 )
  78.               );
  79.         }
  80.         if ($min && $max 15000) {
  81.             //->andWhere('lot.dollars >= :price_min')
  82.             $query
  83.               ->andWhere(
  84.                 $query->expr()->orX(
  85.                   $query->expr()->between('lot.dollars'$min 1000, (int)($max 1000))
  86.                 )
  87.               );
  88.         }
  89.         return $query;
  90.     }
  91.     private function _setQueryRooms($query$min$max)
  92.     {
  93.         if ($max 5) {
  94.             $query
  95.               ->andWhere('lot.rooms <= :rooms_max')
  96.               ->setParameter('rooms_max'$max);
  97.         }
  98.         if ($min 1) {
  99.             $query
  100.               ->andWhere('lot.rooms >= :rooms_min')
  101.               ->setParameter('rooms_min'$min);
  102.         }
  103.         return $query;
  104.     }
  105.     private function _setQueryRoomsT($query$rooms)
  106.     {
  107.         $query
  108.           ->andWhere('lot.rooms between :rooms_min and :rooms_max')
  109.           ->setParameter('rooms_min', !empty($rooms['min']) ? $rooms['min'] : 0)
  110.           ->setParameter('rooms_max', !empty($rooms['max']) ? $rooms['max'] : 10000);
  111.         return $query;
  112.     }
  113.     private function _setQuerySettlement($query$settlement)
  114.     {
  115.         return $query
  116.           ->andWhere('lot.settlement IN (:settlement)')
  117.           ->setParameter('settlement'$settlement);
  118.     }
  119.     private function _setQuerySpace($query$min$max)
  120.     {
  121.         $query->andWhere('lot.area <> 0');
  122.         if ($max 100000) {
  123.             $query
  124.               ->andWhere('lot.area <= :space_max')
  125.               ->setParameter('space_max'$max);
  126.         }
  127.         if ($min 0) {
  128.             $query
  129.               ->andWhere('lot.area >= :space_min')
  130.               ->setParameter('space_min'$min);
  131.         }
  132.         return $query;
  133.     }
  134.     private function _setQuerySubway($query$subway)
  135.     {
  136.         return $query
  137.           ->andWhere('lot.subway2 IN (:subway)')
  138.           ->setParameter('subway'$subway);
  139.     }
  140.     private function _setQueryTag($query$tag)
  141.     {
  142.         return $query
  143.           ->innerJoin('lot.tags''tags')
  144.           ->andWhere('tags.id = :tag')
  145.           ->setParameter('tag'$tag);
  146.     }
  147.     private function _setQueryType($query$type)
  148.     {
  149.         return $query
  150.           ->andWhere('lot.typeHouse IN (:type)')
  151.           ->setParameter('type'$type);
  152.     }
  153.     private function _setQueryTypeLot($query$type)
  154.     {
  155.         return $query
  156.           ->andWhere('lot.typeLot IN (:type)')
  157.           ->setParameter('type'$type);
  158.     }
  159.     public function _setQueryRepair($query$repair)
  160.     {
  161.         return $query
  162.           ->andWhere('lot.repair = :repair')
  163.           ->setParameter('repair'$repair);
  164.     }
  165.     public function _setQuerySale($query$sale)
  166.     {
  167.         return $query
  168.           ->andWhere('lot.oldPrice > 0');
  169.     }
  170.     public function _setQueryStage($query$stage)
  171.     {
  172.         return $query
  173.           ->andWhere('lot.stageHouse IN (:stage)')
  174.           ->setParameter('stage'$stage);
  175.     }
  176.     public function _setQueryText($query$text)
  177.     {
  178.         $text str_replace("%""\%"$text);
  179.         //if (!is_numeric($text)) {
  180.         $query $query
  181.           ->innerJoin("TroikaMainBundle:Address""address""WITH""address.id = lot.address")
  182.           ->innerJoin("TroikaMainBundle:Street""street""WITH""street.id = address.street")
  183.           ->leftJoin("TroikaMainBundle:Complex""complex""WITH""complex.id = lot.complex")
  184.           #->leftJoin("TroikaMainBundle:BusinessCenter", "business", "WITH", "business.id = lot.business")
  185.           ->leftJoin("TroikaMainBundle:CountryCity""cities""WITH""cities.id = lot.countryCity")
  186.           ->leftJoin("TroikaMainBundle:Settlement""settlement""WITH""settlement.id = lot.settlement")
  187.           ->leftJoin("TroikaMainBundle:District3""area""WITH""area.id = lot.district3")
  188.           #->leftJoin("TroikaMainBundle:Subway2", "subway2", "WITH", "subway2.id = lot.subway2")
  189.           ->andWhere(
  190.             $query->expr()->orX(
  191.               $query->expr()->like('lot.id'':text'),
  192.               $query->expr()->like('address.address'':text'),
  193.               $query->expr()->like('street.name'':text'),
  194.               $query->expr()->like('complex.name'':text'),
  195.               $query->expr()->like('settlement.name'':text'),
  196.               $query->expr()->like('cities.name'':text'),
  197.               #$query->expr()->like('business.name', ':text'),
  198.               $query->expr()->like('area.name'':text')
  199.             #$query->expr()->like('subway2.name', ':text')
  200.             )
  201.           )
  202.           ->setParameter('text''%' $text '%');
  203.         /*} else {
  204.             $query = $query
  205.                 ->andWhere('lot.id = :id')
  206.                 ->setParameter('id', $text);
  207.         }*/
  208.         return $query;
  209.     }
  210.     public function _setQueryText2($query$text)
  211.     {
  212.         if (!is_numeric($text)) {
  213.             $query $query
  214.               ->leftJoin("TroikaMainBundle:Address""address""WITH""address.id = lot.address")
  215.               ->leftJoin("TroikaMainBundle:Settlement""settlement""WITH""settlement.id = lot.settlement")
  216.               ->leftJoin("TroikaMainBundle:Highway""highway""WITH""highway.id = lot.highway")
  217.               ->andWhere(
  218.                 $query->expr()->orX(
  219.                   $query->expr()->like('address.address'':text'),
  220.                   $query->expr()->like('settlement.name'':text'),
  221.                   $query->expr()->like('highway.name'':text')
  222.                 )
  223.               )
  224.               ->setParameter('text''%' $text '%');
  225.         } else {
  226.             $query $query
  227.               ->andWhere('lot.id = :id')
  228.               ->setParameter('id'$text);
  229.         }
  230.         return $query;
  231.     }
  232.     public function _setQueryText3($query$text)
  233.     {
  234.         if (!is_numeric($text)) {
  235.             $query $query
  236.               ->leftJoin("TroikaMainBundle:Address""address""WITH""address.id = lot.address")
  237.               ->innerJoin("TroikaMainBundle:Street""street""WITH""street.id = address.street")
  238.               ->leftJoin("TroikaMainBundle:BusinessCenter""business""WITH""business.id = lot.business")
  239.               ->andWhere(
  240.                 $query->expr()->orX(
  241.                   $query->expr()->like('street.name'':text'),
  242.                   $query->expr()->like('address.address'':text'),
  243.                   $query->expr()->like('business.name'':text')
  244.                 )
  245.               )
  246.               ->setParameter('text''%' $text '%');
  247.         } else {
  248.             $query $query
  249.               ->andWhere('lot.id = :id')
  250.               ->setParameter('id'$text);
  251.         }
  252.         return $query;
  253.     }
  254.     public function _setQueryText4($query$text)
  255.     {
  256.         if (!is_numeric($text)) {
  257.             $query $query
  258.               ->leftJoin("TroikaMainBundle:Address""address""WITH""address.id = lot.address")
  259.               ->innerJoin("TroikaMainBundle:Street""street""WITH""street.id = address.street")
  260.               ->leftJoin("TroikaMainBundle:Country""country""WITH""country.id = lot.country")
  261.               ->leftJoin("TroikaMainBundle:CountryCity""city""WITH""city.id = lot.countryCity")
  262.               ->andWhere(
  263.                 $query->expr()->orX(
  264.                   $query->expr()->like('street.name'':text'),
  265.                   $query->expr()->like('address.address'':text'),
  266.                   $query->expr()->like('country.name'':text'),
  267.                   $query->expr()->like('city.name'':text')
  268.                 )
  269.               )
  270.               ->setParameter('text''%' $text '%');
  271.         } else {
  272.             $query $query
  273.               ->andWhere('lot.id = :id')
  274.               ->setParameter('id'$text);
  275.         }
  276.         return $query;
  277.     }
  278.     public function getByBid($id)
  279.     {
  280.         return $this
  281.           ->_em
  282.           ->getRepository('TroikaMainBundle:Lot')
  283.           ->find($id);
  284.     }
  285.     public function getByCityFilter($filter)
  286.     {
  287.         if (!empty($filter["sorter"]) && !empty($filter["sorter"]["order"])
  288.           && $filter["sorter"]["order"] === "price") {
  289.             $filter["sorter"]["order"] = 'dollars';
  290.         }
  291.         // var_dump($filter["sorter"]["order"], $filter["sorter"]["direction"]);die;
  292.         $query $this
  293.           ->_em
  294.           ->getRepository('TroikaMainBundle:Lot')
  295.           ->createQueryBuilder('lot')
  296.           ->where('lot.typeOperation = :operation')
  297.           ->andWhere('lot.showLot = 1')
  298.           ->andWhere('lot.typeLot = :typeLot')
  299.           ->orderBy('lot.' $filter["sorter"]["order"], $filter["sorter"]["direction"])
  300.           ->setParameter('operation'$filter['operation'])
  301.           ->setParameter('typeLot'$filter['lot']);
  302.         if ((!empty($filter["sorter"]["order"])) && $filter["sorter"]["order"] !== "date") {
  303.             // $query->andWhere('lot.price <> 0');
  304.         }
  305.         if ((!empty($filter['price']['max']) && ($filter['price']['max'] < 15000))
  306.           || (!empty($filter['price']['min']) && ($filter['price']['min'] > 0))) {
  307.             $query $this->_setQueryPrice($query$filter['price']['min'], $filter['price']['max']);
  308.         } else {
  309.             if ($filter["sorter"]["order"] === "dollars") {
  310.                 $query $this->_setQueryPrice($query115000);
  311.             }
  312.         }
  313.         if (!empty($filter['text'])) {
  314.             $query $this->_setQueryText($query$filter['text']);
  315.         }
  316.         if (isset($filter['repair'])) {
  317.             $query $this->_setQueryRepair($query$filter['repair']);
  318.         }
  319.         if (!empty($filter['rooms'])) {
  320.             $arr = array();
  321.             $arr['min'] = $filter['rooms'];
  322.             $arr['max'] = $filter['rooms'];
  323.             $query $this->_setQueryRoomsT($query$arr);
  324.             /*$query = $this->_setQueryRoomsT($query, $filter['rooms']);*/
  325.         }
  326.         if ((!empty($filter['space']['max']) && ($filter['space']['max'] < 100000))
  327.           || (!empty($filter['space']['min']) && ($filter['space']['min'] > 0))) {
  328.             $query $this->_setQuerySpace($query$filter['space']['min'], $filter['space']['max']);
  329.         }
  330.         if (!empty($filter['district'])) {
  331.             $query $this->_setQueryDistrict($query$filter['district']);
  332.         }
  333.         if (!empty($filter['tag'])) {
  334.             $query $this->_setQueryTag($query$filter['tag'][0]);
  335.         }
  336.         if (!empty($filter['subway'])) {
  337.             $query $this->_setQuerySubway($query$filter['subway']);
  338.         }
  339.         if (!empty($filter['type'])) {
  340.             $query $this->_setQueryType($query$filter['type']);
  341.         }
  342.         if (!empty($filter['stage'])) {
  343.             $query $this->_setQueryStage($query$filter['stage']);
  344.         }
  345.         if (!empty($filter['sale'])) {
  346.             $query $this->_setQuerySale($query$filter['sale']);
  347.         }
  348.         $queryCount = clone $query;
  349.         return [
  350.           'count'       => $queryCount->select('count(lot)')->getQuery()->getResult()[0][1],
  351.           'lotsAddress' => $query->getQuery()->getResult(),
  352.           'lots'        => $query->setMaxResults(10)->setFirstResult(($filter['page'] - 1) * 10)->getQuery()->getResult(),
  353.         ];
  354.     }
  355.     public function getByCommercialFilter($filter)
  356.     {
  357.         if ($filter["sorter"]["order"] === "price") {
  358.             $filter["sorter"]["order"] = 'dollars';
  359.         }
  360.         $query $this
  361.           ->_em
  362.           ->getRepository('TroikaMainBundle:Lot')
  363.           ->createQueryBuilder('lot')
  364.           ->where('lot.typeOperation = :operation')
  365.           ->andWhere('lot.showLot = 1')
  366.           ->andWhere('lot.typeLot = :typeLot')
  367.           ->orderBy('lot.' $filter["sorter"]["order"], $filter["sorter"]["direction"])
  368.           ->setParameter('operation'$filter['operation'])
  369.           ->setParameter('typeLot'$filter['lot']);
  370.         if ($filter["sorter"]["order"] != "date") {
  371.             // $query->andWhere('lot.price <> 0');
  372.         }
  373.         // var_dump($filter); die;
  374.         if ($filter['price']['max'] < 15000 || $filter['price']['min'] > 0) {
  375.             $query $this->_setQueryPrice($query$filter['price']['min'], $filter['price']['max']);
  376.         } else {
  377.             if ($filter["sorter"]["order"] == "dollars") {
  378.                 $query $this->_setQueryPrice($query115000);
  379.             }
  380.         }
  381.         if ($filter['space']['max'] < 100000 || $filter['space']['min'] > 0) {
  382.             $query $this->_setQuerySpace($query$filter['space']['min'], $filter['space']['max']);
  383.         }
  384.         if (!empty($filter['tag'])) {
  385.             $query $this->_setQueryTag($query$filter['tag'][0]);
  386.         }
  387.         if ($filter['text']) {
  388.             $query $this->_setQueryText3($query$filter['text']);
  389.         }
  390.         if (!empty($filter['district'])) {
  391.             $query $this->_setQueryDistrict($query$filter['district']);
  392.         }
  393.         if (!empty($filter['subway'])) {
  394.             $query $this->_setQuerySubway($query$filter['subway']);
  395.         }
  396.         if (!empty($filter['type'])) {
  397.             $query $this->_setQueryType($query$filter['type']);
  398.         }
  399.         if (!empty($filter['stage'])) {
  400.             $query $this->_setQueryStage($query$filter['stage']);
  401.         }
  402.         if (!empty($filter['sale'])) {
  403.             $query $this->_setQuerySale($query$filter['sale']);
  404.         }
  405.         
  406.         if (isset($filter['repair'])) {
  407.             $query $this->_setQueryRepair($query$filter['repair']);
  408.         }        
  409.         $queryCount = clone $query;
  410.         return [
  411.           'count'       => $queryCount->select('count(lot)')->getQuery()->getResult()[0][1],
  412.           'lotsAddress' => $query->getQuery()->getResult(),
  413.           'lots'        => $query->setMaxResults(10)->setFirstResult(($filter['page'] - 1) * 10)->getQuery()->getResult(),
  414.         ];
  415.     }
  416.     public function getByFilter($filter)
  417.     {
  418.         $q $this
  419.           ->_em
  420.           ->getRepository('TroikaMainBundle:Lot')
  421.           ->createQueryBuilder('lot')
  422.           ->select('lot')
  423.           ->where('lot.typeLot = :typeLot')
  424.           ->andWhere('lot.typeOperation = :typeOperation')
  425.           ->andWhere('lot.showLot = 1')
  426.           ->setParameter('typeOperation'$filter["typeoperation"])
  427.           ->setParameter('typeLot'$filter["typelot"]);
  428.         if ($filter['space'] && ($filter['space']['max'] < 100000 || $filter['space']['min'] > 0)) {
  429.             $q $this->_setQuerySpace($q$filter['space']['min'], $filter['space']['max']);
  430.         }
  431.         if ($filter['price'] && ($filter['price']['max'] < 15000 || $filter['price']['min'] > 0)) {
  432.             $q $this->_setQueryPrice($q$filter['price']['min'], $filter['price']['max']);
  433.         }
  434.         if ($filter['homestead'] && ($filter['homestead']['max'] < 150 || $filter['homestead']['min'] > 0)) {
  435.             $q $this->_setQueryHomesteadArea(
  436.               $q,
  437.               $filter['homestead']['min'],
  438.               $filter['homestead']['max']
  439.             );
  440.         }
  441.         if ($filter['rooms'] && ($filter['rooms']['max'] <= || $filter['rooms']['min'] >= 1)) {
  442.             $q $this->_setQueryRooms($q$filter['rooms']['min'], $filter['rooms']['max']);
  443.         }
  444.         if ($filter['subway']) {
  445.             $q $this->_setQuerySubway($q$filter['subway']);
  446.         }
  447.         if ($filter['stage']) {
  448.             $q $this->_setQueryStage($q$filter['stage']);
  449.         }
  450.         if ($filter['highway']) {
  451.             $q $this->_setQueryHighway($q$filter['highway']);
  452.         }
  453.         if ($filter['settlement']) {
  454.             $q $this->_setQuerySettlement($q$filter['settlement']);
  455.         }
  456.         if ($filter['type']) {
  457.             $q $this->_setQueryType($q$filter['type']);
  458.         }
  459.         if ($filter['district']) {
  460.             $q $this->_setQueryDistrict($q$filter['district']);
  461.         }
  462.         if (isset($filter['repair'])) {
  463.             $q $this->_setQueryRepair($q$filter['repair']);
  464.         }
  465.         return $q
  466.           ->getQuery()
  467.           ->getResult();
  468.     }
  469.     public function getByForeignFilter($filter)
  470.     {
  471.         if ($filter["sorter"]["order"] === "price") {
  472.             $filter["sorter"]["order"] = 'dollars';
  473.         }
  474.         $query $this
  475.           ->_em
  476.           ->getRepository('TroikaMainBundle:Lot')
  477.           ->createQueryBuilder('lot')
  478.           ->where('lot.typeOperation = :operation')
  479.           ->andWhere('lot.showLot = 1')
  480.           ->andWhere('lot.typeLot = :typeLot')
  481.           ->orderBy('lot.' $filter["sorter"]["order"], $filter["sorter"]["direction"])
  482.           ->setParameter('operation'$filter['operation'])
  483.           ->setParameter('typeLot'$filter['lot']);
  484.         if ($filter["sorter"]["order"] !== "date") {
  485.             // $query->andWhere('lot.price <> 0');
  486.         }
  487.         if ($filter['space']['max'] < 100000 || $filter['space']['min'] > 0) {
  488.             $query $this->_setQuerySpace($query$filter['space']['min'], $filter['space']['max']);
  489.         }
  490.         // var_dump($filter); die;
  491.         if ($filter['price']['max'] < 15000 || $filter['price']['min'] > 0) {
  492.             $query $this->_setQueryPrice($query$filter['price']['min'], $filter['price']['max']);
  493.         } else {
  494.             if ($filter["sorter"]["order"] == "dollars") {
  495.                 $query $this->_setQueryPrice($query115000);
  496.             }
  497.         }
  498.         if (!empty($filter['tag'])) {
  499.             $query $this->_setQueryTag($query$filter['tag'][0]);
  500.         }
  501.         if (!empty($filter['text'])) {
  502.             $query $this->_setQueryText4($query$filter['text']);
  503.         }
  504.         if (!empty($filter['country'])) {
  505.             $query $this->_setQueryCountry($query$filter['country']);
  506.         }
  507.         if (!empty($filter['countryCity'])) {
  508.             $query $this->_setQueryCountryCity($query$filter['countryCity']);
  509.         }
  510.         if (!empty($filter['type'])) {
  511.             $query $this->_setQueryType($query$filter['type']);
  512.         }
  513.         if (!empty($filter['sale'])) {
  514.             $query $this->_setQuerySale($query$filter['sale']);
  515.         }
  516.         if (isset($filter['repair'])) {
  517.             $query $this->_setQueryRepair($query$filter['repair']);
  518.         }
  519.         if (!empty($filter['rooms'])) {
  520.             $arr = array();
  521.             $arr['min'] = $filter['rooms'];
  522.             $arr['max'] = $filter['rooms'];
  523.             $query $this->_setQueryRoomsT($query$arr);
  524.             /*$query = $this->_setQueryRoomsT($query, $filter['rooms']);*/
  525.         }
  526.         $queryCount = clone $query;
  527.         return [
  528.           'count'       => $queryCount->select('count(lot)')->getQuery()->getResult()[0][1],
  529.           'lotsAddress' => $query->getQuery()->getResult(),
  530.           'lots'        => $query->setMaxResults(10)->setFirstResult(($filter['page'] - 1) * 10)->getQuery()->getResult(),
  531.         ];
  532.     }
  533.     public function getBySpecialFilter($filter)
  534.     {
  535.         if ($filter["sorter"]["order"] == "price") {
  536.             $filter["sorter"]["order"] = 'dollars';
  537.         }
  538.         $query $this
  539.           ->_em
  540.           ->getRepository('TroikaMainBundle:Lot')
  541.           ->createQueryBuilder('lot')
  542.           ->where('lot.exclusive = :exclusive')
  543.           ->andWhere('lot.showLot = 1')
  544.           ->andWhere('lot.typeLot <> 5')
  545.           ->orderBy('lot.' $filter["sorter"]["order"], $filter["sorter"]["direction"])
  546.           ->setParameter('exclusive'true);
  547.         if (!empty($filter['type'])) {
  548.             $query $this->_setQueryTypeLot($query$filter['type']);
  549.         }
  550.         if (isset($filter['repair'])) {
  551.             $query $this->_setQueryRepair($query$filter['repair']);
  552.         }
  553.         $queryCount = clone $query;
  554.         return [
  555.           'count'       => $queryCount->select('count(lot)')->getQuery()->getResult()[0][1],
  556.           'lotsAddress' => $query->getQuery()->getResult(),
  557.           'lots'        => $query->setMaxResults(10)->setFirstResult(($filter['page'] - 1) * 10)->getQuery()->getResult(),
  558.         ];
  559.     }
  560.     public function getBySuburbanFilter($filter)
  561.     {
  562.         if ($filter["sorter"]["order"] === "price") {
  563.             $filter["sorter"]["order"] = 'dollars';
  564.         }
  565.         $query $this
  566.           ->_em
  567.           ->getRepository('TroikaMainBundle:Lot')
  568.           ->createQueryBuilder('lot')
  569.           ->where('lot.typeOperation = :operation')
  570.           ->andWhere('lot.showLot = 1')
  571.           ->andWhere('lot.typeLot = :typeLot')
  572.           ->orderBy('lot.' $filter["sorter"]["order"], $filter["sorter"]["direction"])
  573.           ->setParameter('operation'$filter['operation'])
  574.           ->setParameter('typeLot'$filter['lot']);
  575.         if (isset($filter['repair'])) {
  576.             $query $this->_setQueryRepair($query$filter['repair']);
  577.         }
  578.         if (
  579.           (!empty($filter['space']['max'])
  580.             && $filter['space']['max'] < 100000)
  581.           || (!empty($filter['space']['min'])
  582.             && $filter['space']['min'] > 0)) {
  583.             $query->andWhere('lot.area <> 0');
  584.             $query $this->_setQuerySpace($query$filter['space']['min'], $filter['space']['max']);
  585.         }
  586.         if (
  587.           (!empty($filter['price']['max'])
  588.           && $filter['price']['max'] < 15000)
  589.           || (!empty($filter['price']['min'])
  590.             && $filter['price']['min'] > 0)) {
  591.             $query $this->_setQueryPrice($query$filter['price']['min'], $filter['price']['max']);
  592.         } else {
  593.             if (!empty($filter["sorter"]["order"]) && $filter["sorter"]["order"] === "dollars") {
  594.                 $query $this->_setQueryPrice($query115000);
  595.             }
  596.         }
  597.         if (!empty($filter['text'])) {
  598.             $query $this->_setQueryText2($query$filter['text']);
  599.         }
  600.         if ((!empty($filter['distance']['max']) && $filter['distance']['max'] < 50) ||
  601.           (!empty($filter['distance']['min']) && $filter['distance']['min'] > 0)) {
  602.             $query $this->_setQueryDistance($query$filter['distance']['min'], $filter['distance']['max']);
  603.         }
  604.         if (!empty($filter['highway'])) {
  605.             $query $this->_setQueryHighway($query$filter['highway']);
  606.         }
  607.         if (!empty($filter['settlement'])) {
  608.             $query $this->_setQuerySettlement($query$filter['settlement']);
  609.         }
  610.         if (!empty($filter['type'])) {
  611.             $query $this->_setQueryType($query$filter['type']);
  612.         }
  613.         if (!empty($filter['tag'])) {
  614.             $query $this->_setQueryTag($query$filter['tag'][0]);
  615.         }
  616.         if (!empty($filter['stage'])) {
  617.             $query $this->_setQueryStage($query$filter['stage']);
  618.         }
  619.         if (!empty($filter['sale'])) {
  620.             $query $this->_setQuerySale($query$filter['sale']);
  621.         }
  622.         if (isset($filter['repair'])) {
  623.             $query $this->_setQueryRepair($query$filter['repair']);
  624.         }
  625.         if (!empty($filter['rooms'])) {
  626.             
  627.             $arr = array();
  628.             $arr['min'] = $filter['rooms'];
  629.             $arr['max'] = $filter['rooms'];
  630.             $query $this->_setQueryRoomsT($query$arr);
  631.             /*$query = $this->_setQueryRoomsT($query, $filter['rooms']);*/
  632.         }
  633.         $queryCount = clone $query;
  634.         return [
  635.           'count'       => $queryCount->select('count(lot)')->getQuery()->getResult()[0][1],
  636.           'lotsAddress' => $query->getQuery()->getResult(),
  637.           'lots'        => $query->setMaxResults(10)->setFirstResult(($filter['page'] - 1) * 10)->getQuery()->getResult(),
  638.           'query'       => $query->getQuery()->getDql(),
  639.         ];
  640.     }
  641.     public function getComplexes()
  642.     {
  643.         return $this
  644.           ->_em
  645.           ->getRepository('TroikaMainBundle:Complex')
  646.           ->findAll();
  647.     }
  648.     public function getComplexesList($r)
  649.     {
  650.         $query $this
  651.           ->_em
  652.           ->getRepository('TroikaMainBundle:ComplexPage')
  653.           ->createQueryBuilder('c')
  654.           ->andWhere('c.isVisible = 1')
  655.           ->orderBy('c.id''desc');
  656.         if ($district $r->get('district')) {
  657.             $query
  658.               ->andWhere('c.area2 IN (:district)')
  659.               ->setParameter('district'$district);
  660.         }
  661.         if ($subway $r->get('subway')) {
  662.             $query
  663.               ->andWhere('c.subway2 IN (:subway)')
  664.               ->setParameter('subway'$subway);
  665.         }
  666.         if ($type $r->get('type')) {
  667.             $query
  668.               ->andWhere('c.typeComplex IN (:type)')
  669.               ->setParameter('type'$type);
  670.         }
  671.         if ($stage $r->get('stage')) {
  672.             $query
  673.               ->andWhere('c.stageComplex IN (:stage)')
  674.               ->setParameter('stage'$stage);
  675.         }
  676.         if ($text $r->get('text')) {
  677.             $text str_replace("%""\%"$text);
  678.             $query
  679.               ->andWhere($query->expr()->like('c.name'':text'))
  680.               ->setParameter('text'$text '%');
  681.         }
  682.         $page $r->get('page') ?: 1;
  683.         $query $query->getQuery();
  684.         $complexes $this->paginator->paginate(
  685.           $query,
  686.           $page,
  687.           10
  688.         );
  689.         return $complexes;
  690.     }
  691.     public function getEmptyPage()
  692.     {
  693.         return $this->paginator->paginate(
  694.           [],
  695.           0,
  696.           10
  697.         );
  698.     }
  699.     public function getFave($lots)
  700.     {
  701.         return $this
  702.           ->_em
  703.           ->getRepository('TroikaMainBundle:Lot')
  704.           ->createQueryBuilder('lot')
  705.           ->where('lot.id IN (:ids)')
  706.           ->setParameter('ids'$lots)
  707.           ->getQuery()
  708.           ->getResult();
  709.     }
  710.     public function getForPartner($i)
  711.     {
  712.         return $lot $this
  713.           ->_em
  714.           ->getRepository('TroikaMainBundle:Lot')
  715.           ->findBy(['typeLot' => $i]);
  716.     }
  717.     public function getForTypeById($id$type)
  718.     {
  719.         $lot $this
  720.           ->_em
  721.           ->getRepository('TroikaMainBundle:Lot')
  722.           ->findBy(
  723.             [
  724.               'id'      => $id,
  725.               'typeLot' => $type//,
  726.                 // 'showLot' => true
  727.             ]
  728.           );
  729.         return ((is_countable($lot) ? count($lot) : 0) === 0) ? false $lot[0];
  730.     }
  731.     public function getLot($id)
  732.     {
  733.         return $this
  734.           ->_em
  735.           ->getRepository('TroikaMainBundle:Lot')
  736.           ->find($id);
  737.     }
  738.     public function getLotAddresses($typeLot$typeOperation)
  739.     {
  740.         $lots $this
  741.           ->_em
  742.           ->getRepository('TroikaMainBundle:Lot')
  743.           ->findBy(['typeLot' => $typeLot'typeOperation' => $typeOperation'showLot' => true]);
  744.         $result = [];
  745. /** @var Lot $lot */
  746.         foreach ($lots as $lot) {
  747.             if ($lot->getAddress()) {
  748.                 $address "";
  749.                 if ($lot->getTypeLot()->getId() == 2) {
  750.                     $address "Московская область ";
  751.                 }
  752.                 if ($lot->getTypeLot()->getId() == || $lot->getTypeLot()->getId() == 3) {
  753.                     $address "Москва ";
  754.                 } else {
  755.                     if ($lot->getCountry()) {
  756.                         $address .= $lot->getCountry()->getName();
  757.                         if ($lot->getCountryCity()) {
  758.                             $address .= " " $lot->getCountryCity()->getName();
  759.                         }
  760.                     }
  761.                 }
  762.                 $address .= " " $lot->getAddress()->getAddress();
  763.                 // if ($lot->getAddress()->getLat() && $lot->getTypeLot()->getId() != 2) {
  764.                 //     $address = $lot->getAddress()->getLat()." ".$lot->getAddress()->getLng();
  765.                 // }
  766.                 if ($lot->getTypeLot()->getId() == 2) {
  767.                     if ($lot->getSettlement()) {
  768.                         $address $lot->getSettlement()->getName();
  769.                     } else {
  770.                         if ($lot->getHighway()) {
  771.                             $address "Московская область ";
  772.                             $address .= " " $lot->getHighway()->getOnSite() . ", " $lot->getMkadDistance() . " км";
  773.                         }
  774.                     }
  775.                 }
  776.                 $result[] = [
  777.                   'id'      => $lot->getId(),
  778.                   'address' => $address,
  779.                   'coord'   => [$lot->getX(), $lot->getY()],
  780.                     // 'string' => is_null($lot->getAddress()->getStreet()) ? $lot->getAddressString() : $lot->getAddress()->getStreet() . $lot->getAddress()->getHome(),
  781.                   'price'   => $lot->getPrice(),
  782.                 ];
  783.             }
  784.         }
  785.         return $result;
  786.     }
  787.     public function getLotsForFeed()
  788.     {
  789.         return $this
  790.           ->_em
  791.           ->getRepository('TroikaMainBundle:Lot')
  792.           ->createQueryBuilder('lot')
  793.           ->select('lot')
  794.           ->where('lot.typeLot in (1,2)')
  795.           ->andWhere('lot.showLot = 1')
  796.           ->andWhere('lot.typeOperation IN (1,2)')
  797.           ->getQuery()
  798.           ->getResult();
  799.     }
  800.     public function getLotsForFeedCian()
  801.     {
  802.         return $this
  803.           ->_em
  804.           ->getRepository('TroikaMainBundle:Lot')
  805.           ->createQueryBuilder('lot')
  806.           ->select('lot')
  807.           ->where('lot.typeLot in (1,2,3)')
  808.           ->andWhere('lot.typeOperation IN (1,2)')
  809.           ->andWhere('lot.showLot = 1')
  810.           ->getQuery()
  811.           ->getResult();
  812.     }
  813.     public function getLotsForFeedCianCom()
  814.     {
  815.         return $this
  816.           ->_em
  817.           ->getRepository('TroikaMainBundle:Lot')
  818.           ->createQueryBuilder('lot')
  819.           ->select('lot')
  820.           ->where('lot.typeLot = 3')
  821.           ->andWhere('lot.typeOperation IN (1,2)')
  822.           ->andWhere('lot.showLot = 1')
  823.           ->getQuery()
  824.           ->getResult();
  825.     }
  826.     public function getLotsForFeedForeign()
  827.     {
  828.         return $this
  829.           ->_em
  830.           ->getRepository('TroikaMainBundle:Lot')
  831.           ->createQueryBuilder('lot')
  832.           ->select('lot')
  833.           ->andWhere('lot.typeOperation IN (1,2)')
  834.           ->andWhere('lot.showLot = 1')
  835.           ->getQuery()
  836.           ->getResult();
  837.     }
  838.     public function getLotsForFeedKvadroom()
  839.     {
  840.         return $this
  841.           ->_em
  842.           ->getRepository('TroikaMainBundle:Lot')
  843.           ->createQueryBuilder('lot')
  844.           ->select('lot')
  845.           ->where('lot.typeLot = 1')
  846.           ->andWhere('lot.typeOperation = 1')
  847.           ->andWhere('lot.showLot = 1')
  848.           ->getQuery()
  849.           ->getResult();
  850.     }
  851.     public function getLotsForFeedKvadroomCom()
  852.     {
  853.         return $this
  854.           ->_em
  855.           ->getRepository('TroikaMainBundle:Lot')
  856.           ->createQueryBuilder('lot')
  857.           ->select('lot')
  858.           ->where('lot.typeLot = 3')
  859.           ->andWhere('lot.typeOperation = 1')
  860.           ->andWhere('lot.showLot = 1')
  861.           ->getQuery()
  862.           ->getResult();
  863.     }
  864.     public function getLotsForFeedKvadroomSub()
  865.     {
  866.         return $this
  867.           ->_em
  868.           ->getRepository('TroikaMainBundle:Lot')
  869.           ->createQueryBuilder('lot')
  870.           ->select('lot')
  871.           ->where('lot.typeLot = 2')
  872.           ->andWhere('lot.typeOperation = 1')
  873.           ->andWhere('lot.showLot = 1')
  874.           //->andWhere('lot.typeHouse.name in ("","","")')
  875.           ->getQuery()
  876.           ->getResult();
  877.     }
  878.     public function getLotsForFeedRbc($s)
  879.     {
  880.         $q $this
  881.           ->_em
  882.           ->getRepository('TroikaMainBundle:Lot')
  883.           ->createQueryBuilder('lot')
  884.           ->select('lot')
  885.           ->where("lot.typeLot = $s")
  886.           ->andWhere('lot.showLot = 1')
  887.           ->andWhere('lot.typeOperation IN (1,2)')//                    ->setMaxResults(15);
  888.         ;
  889.         if ($s == '1') {
  890.             $q->andWhere('lot.rooms > 0');
  891.         }
  892.         if ($s == '2') {
  893.             $q->andWhere("lot.price is not null and lot.area is not null and lot.description is not null and lot.rooms is not null");
  894.         }
  895.         if ($s == '3') {
  896.             $q->andWhere(
  897.               "lot.price is not null and lot.area is not null and lot.subway2 is not null and lot.livArea is not null and lot.kitArea is not null and lot.description is not null and lot.rooms is not null"
  898.             );
  899.         }
  900.         return $q
  901.           ->getQuery()
  902.           ->getResult();
  903.     }
  904.     public function getLotsForFeedRbcTest($s)
  905.     {
  906.         $q $this
  907.           ->_em
  908.           ->getRepository('TroikaMainBundle:Lot')
  909.           ->createQueryBuilder('lot')
  910.           ->select('lot')
  911.           ->where("lot.typeLot = $s")
  912.           ->andWhere('lot.showLot = 1')
  913.           ->andWhere('lot.typeOperation IN (1,2)')
  914.           ->andWhere(
  915.             "lot.price is not null and lot.area is not null and lot.subway2 is not null and lot.livArea is not null and lot.kitArea is not null and lot.description is not null and lot.rooms is not null"
  916.           )
  917.           ->setMaxResults(50);
  918.         if ($s == '1') {
  919.             $q->andWhere('lot.rooms > 0');
  920.         }
  921.         $arr $q
  922.           ->getQuery()
  923.           ->getResult();
  924.         $cb = function ($value) {
  925.             if (is_numeric($value->getFloor())) {
  926.                 return true;
  927.             } else {
  928.                 return false;
  929.             }
  930.         };
  931.         $arr array_filter($arr$cb);
  932.         return $arr;
  933.     }
  934.     public function getPageByType($options)
  935.     {
  936.         
  937.         $query $this
  938.           ->_em
  939.           ->getRepository('TroikaMainBundle:Lot')
  940.           ->createQueryBuilder('lot')
  941.           ->select('lot')
  942.           ->where('lot.typeLot = :type')
  943.           ->andWhere('lot.typeOperation = :operation')
  944.           ->andWhere('lot.showLot = 1')
  945.           ->setParameter('type'$options['type'])
  946.           ->setParameter('operation'$options['operation'])
  947.           ->orderBy('lot.date''desc');
  948.         if ($options['price']['max'] < 15000 || $options['price']['min'] > 0) {
  949.             $query $this->_setQueryPrice($query$options['price']['min'], $options['price']['max']);
  950.         }
  951.         if ($options['space']['max'] < 100000 || $options['space']['min'] > 0) {
  952.             $query $this->_setQuerySpace($query$options['space']['min'], $options['space']['max']);
  953.         }
  954.         if (isset($options['rooms'])) {
  955.             $arr = array();
  956.             $arr['min'] = $options['rooms'];
  957.             $arr['max'] = $options['rooms'];
  958.             //$query = $this->_setQueryRoomsT($query, $options['rooms']);
  959.             $query $this->_setQueryRoomsT($query$arr);
  960.         }
  961.         if (isset($options['repair'])) {
  962.             $query $this->_setQueryRepair($query$options['repair']);
  963.         }
  964.         if ($options['sale']) {
  965.             $query $this->_setQuerySale($query);
  966.         }
  967.         $opts $_GET;
  968.         if(isset($opts['page'])){
  969.             unset($opts['page']);
  970.         }
  971.         $query $query->getQuery();
  972.         $pagination $this->paginator->paginate(
  973.           $query,
  974.           $options['page'],
  975.           10,
  976.           ['distinct' => false]
  977.         );
  978.         return $pagination;
  979.     }
  980.     public function getRecent()
  981.     {
  982.         $city $this
  983.           ->_em
  984.           ->getRepository('TroikaMainBundle:Lot')
  985.           ->createQueryBuilder("lot")
  986.           ->where('lot.typeLot = :type')
  987.           ->andWhere('lot.showLot = 1')
  988.           ->orderBy("lot.date""DESC")
  989.           ->setParameter('type'1)
  990.           ->setMaxResults(3)
  991.           ->getQuery()
  992.           ->getResult();
  993.         $suburban $this
  994.           ->_em
  995.           ->getRepository('TroikaMainBundle:Lot')
  996.           ->createQueryBuilder("lot")
  997.           ->where('lot.typeLot = :type')
  998.           ->andWhere('lot.showLot = 1')
  999.           ->orderBy("lot.date""DESC")
  1000.           ->setParameter('type'2)
  1001.           ->setMaxResults(3)
  1002.           ->getQuery()
  1003.           ->getResult();
  1004.         $commercial $this
  1005.           ->_em
  1006.           ->getRepository('TroikaMainBundle:Lot')
  1007.           ->createQueryBuilder("lot")
  1008.           ->where('lot.typeLot = :type')
  1009.           ->andWhere('lot.showLot = 1')
  1010.           ->orderBy("lot.date""DESC")
  1011.           ->setParameter('type'3)
  1012.           ->setMaxResults(3)
  1013.           ->getQuery()
  1014.           ->getResult();
  1015.         $foreign $this
  1016.           ->_em
  1017.           ->getRepository('TroikaMainBundle:Lot')
  1018.           ->createQueryBuilder("lot")
  1019.           ->where('lot.typeLot = :type')
  1020.           ->andWhere('lot.showLot = 1')
  1021.           ->orderBy("lot.date""DESC")
  1022.           ->setParameter('type'4)
  1023.           ->setMaxResults(3)
  1024.           ->getQuery()
  1025.           ->getResult();
  1026.         return array_merge($city$suburban$foreign$commercial);
  1027.     }
  1028.     public function getSimilar(Lot $lot)
  1029.     {
  1030.         $similar $this
  1031.           ->_em
  1032.           ->getRepository('TroikaMainBundle:Lot')
  1033.           ->createQueryBuilder('lot');
  1034.         // if ($lot->getTypeLot()->getId() == 1 && $lot->getRooms()) {
  1035.         //    $similar->addOrderBy('ABS(:ORooms - lot.rooms)', 'ASC');
  1036.         //    $similar->setParameter('ORooms', $lot->getRooms());
  1037.         // }
  1038.         if ($lot->getMkadDistance()) {
  1039.             $similar->addOrderBy('ABS(:OmkadDistance - lot.mkadDistance)''ASC');
  1040.             $similar->setParameter('OmkadDistance'$lot->getMkadDistance());
  1041.         }
  1042.         $similar->setMaxResults(13);
  1043. //        $similar->andWhere('lot.livArea is not NULL');
  1044.         $similar->andWhere('lot.typeOperation=:Otypeop');
  1045.         $similar->andWhere('lot.id <> :Oid');
  1046.         $similar->andWhere('lot.showLot=1');
  1047.         $similar->andWhere('lot.typeLot=:Otypelot');
  1048.         $similar->setParameter('Otypeop'$lot->getTypeOperation());
  1049.         $similar->setParameter('Otypelot'$lot->getTypeLot());
  1050.         $similar->setParameter('Oid'$lot->getId());
  1051.         if ($lot->getTypeLot()->getId() == 2) {
  1052.             if ($lot->getDollars()) {
  1053.                 $similar->addOrderBy('ABS(:Oprice - lot.dollars)''ASC');
  1054.                 $similar->setParameter('Oprice'$lot->getDollars());
  1055.             }
  1056.             $similar->andWhere('lot.mkadDistance is NOT NULL');
  1057.             $similar->addOrderBy('ABS(:Ohighway - lot.highway)''ASC');
  1058.             $similar->setParameter('Ohighway'$lot->getHighway()->getId());
  1059.         } elseif ($lot->getTypeLot()->getId() == || $lot->getTypeLot()->getId() == 3) {
  1060.             if ($lot->getDollars()) {
  1061.                 $similar->addOrderBy('ABS(:Oprice - lot.dollars)''ASC');
  1062.                 $similar->setParameter('Oprice'$lot->getDollars());
  1063.             }
  1064.             $similar->andWhere('lot.dollars is not NULL');
  1065.             $similar->andWhere('lot.dollars is not NULL');
  1066.             if ($lot->getTypeLot()->getId() == && $lot->getDistrict3()) {
  1067.                 $similar->andWhere('lot.district3=:Odistrict');
  1068.                 $similar->setParameter('Odistrict'$lot->getDistrict3()->getId());
  1069.             } else {
  1070.                /* if ($lot->getTypeLot()->getId() == 1 && $lot->getDistrict2()) {
  1071.                     $similar->andWhere('lot.district2=:Odistrict');
  1072.                     $similar->setParameter('Odistrict', $lot->getDistrict2()->getId());
  1073.                 } else { */
  1074.                     if ($lot->getTypeLot()->getId() == && $lot->getDistrict()) {
  1075.                         $similar->andWhere('lot.district=:Odistrict');
  1076.                         $similar->setParameter('Odistrict'$lot->getDistrict()->getId());
  1077.                     }
  1078.                 // }
  1079.             }
  1080.         } else {
  1081.             $similar->andWhere('lot.country=:Odistrict');
  1082.             $similar->setParameter('Odistrict'$lot->getCountry()->getId());
  1083.         }
  1084.         $similar $similar->getQuery();
  1085.         $similar $similar->getResult();
  1086.         return $similar;
  1087.     }
  1088.     public function getSimilarCom(Lot $lot)
  1089.     {
  1090.         $similar $this
  1091.           ->_em
  1092.           ->getRepository('TroikaMainBundle:Lot')
  1093.           ->createQueryBuilder('lot');
  1094.         $similar->andWhere('lot.typeOperation=:Otypeop');
  1095.         $similar->andWhere('lot.id <> :Oid');
  1096.         $similar->andWhere('lot.price > :Oprice');
  1097.         $similar->andWhere('lot.dollars > :Oprice');
  1098.         $similar->andWhere('lot.showLot=1');
  1099.         $similar->andWhere('lot.typeLot=:Otypelot');
  1100.         $similar->andWhere('lot.typeHouse=:OtypeHouse');
  1101.         $similar->setParameter('Otypeop'$lot->getTypeOperation());
  1102.         $similar->setParameter('Otypelot'$lot->getTypeLot());
  1103.         $similar->setParameter('OtypeHouse'$lot->getTypeHouse());
  1104.         $similar->setParameter('Oid'$lot->getId());
  1105.         $similar->setParameter('Oprice'1);
  1106.         $similar $similar->getQuery();
  1107.         $similar $similar->getResult();
  1108.         return $similar;
  1109.     }
  1110.     public function getSpecial()
  1111.     {
  1112.         $query $this
  1113.           ->_em
  1114.           ->getRepository('TroikaMainBundle:Lot')
  1115.           ->createQueryBuilder('lot')
  1116.           ->where('lot.exclusive = :exclusive')
  1117.           ->andWhere('lot.showLot = 1')
  1118.           ->andWhere('lot.typeLot <> 5')
  1119.           ->orderBy('lot.date''desc')
  1120.           ->setParameter('exclusive'true)
  1121.           ->getQuery()
  1122.           ->getResult();
  1123.         $pagination $this->paginator->paginate(
  1124.           $query,
  1125.           1,
  1126.           10
  1127.         );
  1128.         return $pagination;
  1129.     }
  1130.     public function getSpecialLotAddresses()
  1131.     {
  1132.         $lots $query $this
  1133.           ->_em
  1134.           ->getRepository('TroikaMainBundle:Lot')
  1135.           ->createQueryBuilder('lot')
  1136.           ->where('lot.exclusive = :exclusive')
  1137.           // ->andWhere('lot.showLot = 1')
  1138.           ->andWhere('lot.typeLot <> 5')
  1139.           ->orderBy('lot.price''desc')
  1140.           ->setParameter('exclusive'true)
  1141.           ->getQuery()
  1142.           ->getResult();;
  1143.         $result = [];
  1144.         foreach ($lots as $lot) {
  1145.             if ($lot->getAddress()) {
  1146.                 $result[] = [
  1147.                   'id'      => $lot->getId(),
  1148.                   'address' => $lot->getAddress()->getAddress(),
  1149.                   'coord'   => [$lot->getX(), $lot->getY()],
  1150.                     // 'string' => is_null($lot->getAddress()->getStreet()) ? $lot->getAddressString() : $lot->getAddress()->getStreet() . $lot->getAddress()->getHome(),
  1151.                   'price'   => $lot->getPrice(),
  1152.                 ];
  1153.             }
  1154.         }
  1155.         return $result;
  1156.     }
  1157. }