src/Service/HotelService.php line 554

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. use App\Entity\Currency;
  4. use App\Entity\Wishlist;
  5. use App\Interfaces\HotelMongoInterface;
  6. use App\Interfaces\IHotels;
  7. use App\Interfaces\OrderInterface;
  8. use App\Interfaces\ReviewsInterface;
  9. use App\Interfaces\SearchInterface;
  10. use App\Interfaces\StaticDataInterface;
  11. use App\Vendor\Helper;
  12. use App\Vendor\Symfony\HAbstractService;
  13. use Doctrine\ORM\EntityManagerInterface;
  14. use Knp\Component\Pager\PaginatorInterface;
  15. use Symfony\Bundle\FrameworkBundle\Routing\Router;
  16. use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpKernel\KernelInterface;
  19. use Symfony\Contracts\Translation\TranslatorInterface;
  20. class HotelService extends HAbstractService implements IHotels
  21. {
  22.     private PaginatorInterface $paginator;
  23.     private $lang;
  24.     private HotelMongoInterface $hm;
  25.     private ReviewsInterface $reviewsService;
  26.     private StaticDataInterface $staticDataService;
  27.     private SearchInterface $searchService;
  28.     private $searched false;
  29.     private OrderInterface $orderService;
  30.     public function __construct(ContainerBagInterface $bagEntityManagerInterface $emKernelInterface $kernelTranslatorInterface $translator,
  31.                                 PaginatorInterface $paginator,
  32.                                 HotelMongoInterface $hm,
  33.                                 ReviewsInterface $reviewsServiceStaticDataInterface $staticDataService,SearchInterface $searchServiceOrderInterface $orderService){
  34.         parent::__construct($bag,$em,$kernel$translator);
  35.         $this->paginator $paginator;
  36.         $this->hm $hm;
  37.         $this->reviewsService $reviewsService;
  38.         $this->staticDataService $staticDataService;
  39.         $this->searchService $searchService;
  40.         $this->orderService $orderService;
  41.     }
  42.     public function list(Request $request$limit 20){
  43.         $params $this->getRequestParams($request);
  44.         if(isset($params[0])){
  45.             $params["search"]["currency"] = $params[0]["search"]["currency"];
  46.         }
  47.         unset($params["path"]);
  48.         $request->query->remove("path");
  49.         if(isset($params["rating"]) && !empty($params["rating"]) && $params["rating"][0] == "on"){
  50.             unset($params["rating"]);
  51.             $request->query->remove("rating");
  52.         }
  53.         $searchData = [];
  54.         if(isset($params["search"]) && empty($params["search"]["status"])){
  55.             $search $params["search"];
  56.             $currentDay date("Y-m-d");
  57.             $checkIn = empty($search["checkin"]) ? date("Y-m-d"strtotime($currentDay ' +1 day')) : $search["checkin"];
  58.             $checkOut = empty($search["checkout"]) ? date("Y-m-d"strtotime($checkIn ' +1 day')) : $search["checkout"];
  59.             $guestsDefault = [
  60.                 [
  61.                     "adults" => 2,
  62.                     "children" => []
  63.                 ]
  64.             ];
  65.             $guests = empty($search["guests"]) ? $guestsDefault $search["guests"];
  66.             $this->searchService->setRooms($guests);
  67.             if(!empty($search["location"])){
  68.                 $searchData $this->searchService->regionSearch($search["location"],$checkIn,$checkOut$request->getLocale(),$search["currency"],0$search["residency"]);
  69.             }
  70.         }
  71.         if(isset($params["page"])){
  72.             unset($params["page"]);
  73.         }
  74.         if(isset($params["search"])){
  75.             if(!empty($searchData)){
  76.                 $params["id"] = $searchData["ids"];
  77.                 unset($params["search"]);
  78.             } else {
  79.                 $params["id"] = $searchData;
  80.             }
  81.         }
  82. //        if(empty($params['star_rating'])){
  83. //            $params['star_rating'] = [5];
  84. //        }
  85.         $criteria $this->hm->mongoIn($params);
  86.         $hotelsDb 'hotels_'.$request->getLocale();
  87.         $this->hm->select($hotelsDb);
  88.         $postParams $request->request->all();
  89.         if(!empty($postParams)){
  90.             $page $request->request->getInt('page'1);
  91.         } else {
  92.             $page $request->query->getInt('page'1);
  93.         }
  94.         $skip  = ($page 1) * (int)$limit;
  95.         $sort $request->query->get('sort');
  96.         $direction $request->query->get('dir');
  97.         $direction $direction == 'asc' : -1;
  98.         $hotels $this->hm->findBy($criteria,$limit,$skip,$sort,$direction);
  99.         /** @var Router $router */
  100.         $router $this->container->get('router');
  101.         $searchH $request->query->all();
  102.         foreach ($hotels as $ind=>&$hotel){
  103.             if(!empty($searchData) && !empty($searchData["hotels"])){
  104.                 if(!isset($searchData["hotels"][$hotel["id"]])){
  105.                     unset($hotels[$ind]);
  106.                     continue;
  107.                 }
  108.                 foreach ($searchData["hotels"][$hotel["id"]]["rates"] as $index=>$rate){
  109.                     if($rate["allotment"] < 1){
  110.                         unset($searchData["hotels"][$hotel["id"]]["rates"][$index]);
  111.                     }
  112.                 }
  113.                 if(count($searchData["hotels"][$hotel["id"]]["rates"]) == 0){
  114.                     unset($hotels[$ind]);
  115.                     continue;
  116.                 }
  117.                 $rate $searchData["hotels"][$hotel["id"]]["rates"][0];
  118.                 $price = (int)$rate["payment_options"]["payment_types"][0]["show_amount"];
  119.                 $currencyCode $rate["payment_options"]["payment_types"][0]["show_currency_code"];
  120.                 $days Helper::dateDiffInDays($search["checkin"], $search["checkout"]);
  121.                 $hotel["prices"] = [
  122.                     "price" => $price,
  123.                     "day" => $days,
  124.                     "currency" => $this->em->getRepository(Currency::class)->findOneBy(["iso" => $currencyCode])
  125.                 ];
  126.                 $searchH["search"]["hotelId"] = $hotel["id"];
  127.                 $hotel["link"] = $router->generate('app_detail_hotel_detail', ["id"=>$hotel["id"],$searchH]);
  128.             }
  129.             if(isset($hotel["serp_filters"])){
  130.                 foreach ($hotel["serp_filters"] as &$serp_filter){
  131.                     $serp_filter = [
  132.                         "key" =>$serp_filter,
  133.                         "name" =>$this->staticDataService->getSerpFilter($serp_filter$request->getLocale()),
  134.                     ];
  135.                 }
  136.             }
  137. //            $reviews = $this->reviewsService->getReviewsByHotelId($hotel["id"], $request->getLocale());
  138. //
  139.             $score "";
  140.             if(!empty($hotel["reviews"])){
  141.                 $reviews $hotel["reviews"];
  142.                 $reviewsCount count($reviews["reviews"]);
  143.                 $rating $reviews["rating"];
  144.                 if($rating 7){
  145.                     $score self::RATING["Review score"];
  146.                 }
  147.                 if($rating && $rating 8){
  148.                     $score self::RATING["Good"];
  149.                 }
  150.                 if($rating >= && $rating 8.5 ){
  151.                     $score self::RATING["Very Good"];
  152.                 }
  153.                 if($rating >= 8.5 && $rating ){
  154.                     $score self::RATING["Excellent"];
  155.                 }
  156.                 if($rating >= && $rating 9.5 ){
  157.                     $score self::RATING["Wonderful"];
  158.                 }
  159.                 if($rating >= 9.5 && $rating <= 10 ){
  160.                     $score self::RATING["Exceptional"];
  161.                 }
  162.                 $hotel["reviews"] = [
  163.                     "rating" => $rating,
  164.                     "reviewsCount" => $reviewsCount,
  165.                     "score" => $score
  166.                 ];
  167.             }
  168. //            if(empty($reviews)){
  169. //                $hotel["reviews"]["rating"] = 0;
  170. //            } else{
  171. //                $rating = $reviews["rating"];
  172. //                if(!empty($rating)){
  173. //                    $whole = floor($rating);
  174. //                    $remainder = $rating - $whole;
  175. //                    $review["ratingGroup"] = [
  176. //                        "whole" => (int)$whole,
  177. //                        "remainder" => $remainder,
  178. //                    ];
  179. //                }
  180. //                $hotel["reviews"] = $review;
  181. //            }
  182.             $wishlist $this->em->getRepository(Wishlist::class)->findOneBy(["hotelId" => $hotel["id"]]);
  183.             if(!empty($wishlist)){
  184.                 $hotel["wishlist"] = true;
  185.             } else {
  186.                 $hotel["wishlist"] = false;
  187.             }
  188.         }
  189.         $this->hm->select($hotelsDb);
  190.         $totalCount $this->hm->count($criteria);
  191.         if(count($hotels) == 0){
  192.             $totalCount 0;
  193.         }
  194.         $pagination $this->paginator->paginate(
  195.             $hotels,
  196.             $page,
  197.             $limit
  198.         );
  199.         $pagination->setItems($hotels);
  200.         $pagination->setTotalItemCount($totalCount);
  201.         foreach ($pagination->getItems() as &$item){
  202.             if(empty($item["images"])){
  203.                continue;
  204.             }
  205.             foreach ($item["images"] as &$image){
  206.                 $image str_replace('{size}','x500'$image);
  207.             }
  208.         }
  209.         return $pagination;
  210.     }
  211.     public function getByHotelId(string $hotelIdstring $lang){
  212.         $collection 'hotels_'.$lang;
  213.         $this->hm->select($collection);
  214.         $hotel $this->hm->findByKey("id"trim($hotelId));
  215.         return $hotel;
  216.     }
  217.     public function updateOneHotelFromJson($json$lang){
  218.         $collection "hotel_".$lang;
  219.         $this->hm->updateOneFromJson($json$collection);
  220.     }
  221.     public function hotelPage(string $idRequest $request){
  222.         $id trim($id);
  223.         $params $this->getParams();
  224.         $guests = [];
  225.         if(isset($params["search"])){
  226.             $params["search"]["language"] = $request->getLocale();
  227.             $params["search"]["hotelId"] = $id;
  228.             $guests $params["search"]["guests"];
  229.         } else if(!empty($params[0]["search"])){
  230. //            foreach ($params[0]['search']["guests"] as &$room){
  231. //                $item["adults"] = (int)$room["adults"];
  232. //
  233. //                if($room["children"][0] == "NaN"){
  234. //                    $item["children"] = [];
  235. //                } else{
  236. //                    foreach ($room["children"] as $child){
  237. //                        $item["children"][] = (int)$child;
  238. //                    }
  239. //                }
  240. //
  241. //                $guests[] = $item;
  242. //            }
  243.             $params[0]["search"]["language"] = $request->getLocale();
  244.             $guests $params[0]["search"]["guests"];
  245.             $params[0]["search"]["hotelId"] = $id;
  246.         }
  247.         $params["hotelId"] = $id;
  248.         $this->searchService->setRooms($guests);
  249.         if(isset($params["search"])){
  250.             $jsonParams $this->searchService->generateSearchQuery(SearchInterface::HOTEL_PAGE$params["search"]);
  251.         } else {
  252.             $jsonParams $this->searchService->generateSearchQuery(SearchInterface::HOTEL_PAGE$params[0]["search"]);
  253.         }
  254.         $curl curl_init();
  255.         curl_setopt_array($curl, array(
  256.             CURLOPT_URL => 'https://api.worldota.net/api/b2b/v3/search/hp/',
  257.             CURLOPT_USERPWD => $this->bag->get('zstd_user').":".$this->bag->get('zstd_pass'),
  258.             CURLOPT_RETURNTRANSFER => true,
  259.             CURLOPT_ENCODING => '',
  260.             CURLOPT_MAXREDIRS => 10,
  261.             CURLOPT_TIMEOUT => 0,
  262.             CURLOPT_FOLLOWLOCATION => true,
  263.             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  264.             CURLOPT_CUSTOMREQUEST => 'POST',
  265.             CURLOPT_POSTFIELDS => $jsonParams,
  266.             CURLOPT_HTTPHEADER => array(
  267.                 'Content-Type: application/json'
  268.             ),
  269.         ));
  270.         $response curl_exec($curl);
  271.         curl_close($curl);
  272.         $hotelResponseData json_decode($responsetrue);
  273.         $data = [];
  274.         if(empty($hotelResponseData["data"])){
  275.             return $data["hotel"] = [];
  276.         }
  277.         if(empty($hotelResponseData["data"]["hotels"])){
  278.             return $data["hotel"] = [];
  279.         }
  280.         $hotelData $hotelResponseData["data"]["hotels"][0]["rates"];
  281.         $hotelsDb 'hotels_'.$request->getLocale();
  282.         $this->hm->select($hotelsDb);
  283. //        $localData = $this->hm->findByKey('id', $id);
  284. //        if(empty($localData)){
  285. //            return $data["hotel"] = [];
  286. //        }
  287. //        $localData = iterator_to_array($localData[0]);
  288.         $roomGroups = [];
  289.         unset($roomGroup);
  290.         /** @var Router $router */
  291.         $router $this->container->get('router');
  292.         $localData $this->getHotelInfo($id$request->getLocale());
  293.         foreach ($localData["room_groups"] as $roomGroup){
  294.             $roomGroup["images"] = $this->hotelImages($roomGroup["images"]);
  295.             foreach ($hotelData as $hotelDatum){
  296.                 if($hotelDatum["room_data_trans"]["main_name"] == $roomGroup["name_struct"]["main_name"] && $hotelDatum["room_data_trans"]["bedding_type"] == $roomGroup["name_struct"]["bedding_type"]){
  297.                     $hotelDatum["partner_id"] = Helper::uuid4();
  298.                     $hotelDatum["total_taxes_amount"] = $this->orderService->getTotalTaxes($hotelDatum);
  299.                     $roomGroup["rates"][] = $hotelDatum;
  300.                     $roomGroups[$roomGroup["name_struct"]["main_name"]] = $roomGroup;
  301.                 }
  302.             }
  303.         }
  304.         foreach ($roomGroups as &$roomGroup){
  305.             if(isset($roomGroup["room_amenities"])){
  306.                 $roomAmenitiesData = [];
  307.                 foreach ($roomGroup["room_amenities"] as $room_amenity){
  308.                     if(is_array($room_amenity)){
  309.                         continue;
  310.                     }
  311.                     $room_amenity_item = [
  312.                         "key" =>$room_amenity,
  313.                         "name" =>is_array($this->staticDataService->getRoomAmenity($room_amenity$request->getLocale())) ? "" $this->staticDataService->getRoomAmenity($room_amenity$request->getLocale()),
  314.                     ];
  315.                     $roomAmenitiesData[] = $room_amenity_item;
  316.                 }
  317.                 $roomGroup["room_amenities"]= $roomAmenitiesData;
  318.             }
  319.             if(isset($roomGroup["rates"])){
  320.                 foreach ($roomGroup["rates"] as &$rate){
  321.                     if($rate["meal"] != "nomeal"){
  322.                         $meal $this->staticDataService->getMeal($rate["meal"], $request->getLocale());
  323.                         $rate["meal"] = $meal;
  324.                     }
  325.                     if(isset($rate["amenities_data"])){
  326.                         $rateAmenitiesData = [];
  327.                         foreach ($rate["amenities_data"] as $rateAmenities){
  328.                             if(is_array($rateAmenities)){
  329.                                 continue;
  330.                             }
  331.                             $item = [
  332.                                 "key" =>$rateAmenities,
  333.                                 "name" =>$this->staticDataService->getRoomAmenity($rateAmenities$request->getLocale()),
  334.                             ];
  335.                             $rateAmenitiesData[] = $item;
  336.                         }
  337.                         $rate["amenities_data"] = $rateAmenitiesData;
  338.                     }
  339.                 }
  340.             }
  341.         }
  342.         if(!empty($localData["reviews"])){
  343.             $newDetailedRatings = [];
  344.             foreach ($localData["reviews"]["detailed_ratings"] as $key=>$rating){
  345.                 $newKey $this->translator->trans($key);
  346.                 $newDetailedRatings[$newKey] = $rating;
  347.             }
  348.             $localData["reviews"]["detailed_ratings"] = $newDetailedRatings;
  349.         }
  350.         $groups = [];
  351.         foreach ($roomGroups as $group){
  352.             $groups[] = $group;
  353.         }
  354.         $localData["room_groups"] = $groups;
  355.         $localData["images"] = $this->hotelImages($localData["images"]);
  356.         if(isset($localData["serp_filters"])){
  357.             foreach ($localData["serp_filters"] as &$serp_filter){
  358.                 $serp_filter = [
  359.                     "key" =>$serp_filter,
  360.                     "name" =>$this->staticDataService->getSerpFilter($serp_filter$request->getLocale()),
  361.                 ];
  362.             }
  363.         }
  364.         if(isset($localData["facts"]) && isset($localData["facts"]["electricity"]) && isset($localData["facts"]["electricity"]["sockets"])){
  365.             foreach ($localData["facts"]["electricity"]["sockets"] as &$socket){
  366.                 $socket = [
  367.                     "key" =>$socket,
  368.                     "name" =>$this->staticDataService->getSocketType($socket$request->getLocale()),
  369.                 ];
  370.             }
  371.         }
  372.         $wishlist $this->em->getRepository(Wishlist::class)->findOneBy(["hotelId" => $localData["id"]]);
  373.         if(!empty($wishlist)){
  374.             $localData["wishlist"] = true;
  375.         } else {
  376.             $localData["wishlist"] = false;
  377.         }
  378.         $localData["link"] = $router->generate('app_detail_hotel_detail', ["id"=>$id$params]);
  379.         return $localData;
  380.     }
  381.     public function testHotelPage(Request $request$params){
  382.         $hotel $this->getByHotelId($params["search"]["location"], $request->getLocale());
  383.         if(!empty($hotel)){
  384.             $localData iterator_to_array($hotel[0]);
  385.             foreach ($localData["room_groups"] as &$roomGroup){
  386.                 $roomGroup["images"] = $this->hotelImages($roomGroup["images"]);
  387.             }
  388.             $roomGroups = [];
  389.             unset($roomGroup);
  390.             foreach ($localData["room_groups"] as $roomGroup){
  391. //                foreach ($hotelData as $hotelDatum){
  392. //                    if($hotelDatum["room_data_trans"]["main_name"] == $roomGroup["name_struct"]["main_name"] && $hotelDatum["room_data_trans"]["bedding_type"] == $roomGroup["name_struct"]["bedding_type"]){
  393. //                        $roomGroup["rates"][] = $hotelDatum;
  394. //                        $roomGroups[$roomGroup["room_group_id"]] = $roomGroup;
  395. //                    }
  396. //                }
  397.                 if(isset($roomGroup["room_amenities"])){
  398.                     foreach ($roomGroup["room_amenities"] as &$room_amenity){
  399.                         $name $this->staticDataService->getRoomAmenity($room_amenity$request->getLocale());
  400.                         if(empty($name)){
  401.                             continue;
  402.                         }
  403.                         $room_amenity = [
  404.                             "key" =>$room_amenity,
  405.                             "name" =>$this->staticDataService->getRoomAmenity($room_amenity$request->getLocale()),
  406.                         ];
  407.                     }
  408.                 }
  409.                 if(isset($roomGroup["rates"])){
  410.                     foreach ($roomGroup["rates"] as &$rate){
  411.                         if($rate["meal"] != "nomeal"){
  412.                             $rate["meal"] = $this->staticDataService->getMeal($rate["meal"], $request->getLocale());
  413.                         }
  414.                         if(isset($rate["amenities_data"])){
  415.                             foreach ($rate["amenities_data"] as &$rateAmenities){
  416.                                 $rateAmenities = [
  417.                                     "key" =>$rateAmenities,
  418.                                     "name" =>$this->staticDataService->getRoomAmenity($rateAmenities$request->getLocale()),
  419.                                 ];
  420.                             }
  421.                         }
  422.                     }
  423.                 }
  424.             }
  425.             $localData["room_groups"] = $roomGroups;
  426.             $localData["images"] = $this->hotelImages($localData["images"]);
  427.             if(isset($localData["serp_filters"])){
  428.                 foreach ($localData["serp_filters"] as &$serp_filter){
  429.                     $serp_filter = [
  430.                         "key" =>$serp_filter,
  431.                         "name" =>$this->staticDataService->getSerpFilter($serp_filter$request->getLocale()),
  432.                     ];
  433.                 }
  434.             }
  435.             if(isset($localData["facts"]) && isset($localData["facts"]["electricity"]) && isset($localData["facts"]["electricity"]["sockets"])){
  436.                 foreach ($localData["facts"]["electricity"]["sockets"] as &$socket){
  437.                     $socket = [
  438.                         "key" =>$socket,
  439.                         "name" =>$this->staticDataService->getSocketType($socket$request->getLocale()),
  440.                     ];
  441.                 }
  442.             }
  443.             return $localData;
  444.         }
  445.     }
  446.     public function guestsRoomsDaysCount(&$params){
  447.         $dateDiff Helper::dateDiffInDays($params["search"]["checkin"], $params["search"]["checkout"]);
  448.         $roomsCount count($params["search"]["guests"]);
  449.         $gustsCount 0;
  450.         foreach ($params["search"]["guests"] as $room){
  451.             $adults = (int)$room["adults"];
  452.             if($room["children"][0] == "NaN"){
  453.                 $children 0;
  454.             } else {
  455.                 $children count($room["children"]);
  456.             }
  457.             $roomGusts $adults $children;
  458.             $gustsCount += $roomGusts;
  459.         }
  460.         $params["roomsCount"] = $roomsCount;
  461.         $params["guestsCount"] = $gustsCount;
  462.         $params["days"] = (int)$dateDiff;
  463.     }
  464.     public function featuredHotels($country){
  465.         /** @var Router $router */
  466.         $router $this->container->get('router');
  467.         $collection 'hotels_'.$this->request->getLocale();
  468.         $this->hm->select($collection);
  469.         $results $this->hm->findBy(['$and' =>[["reviews.rating" => ['$gt' => 9]], ["star_rating"=>[ '$gt' => 4]]]],4);
  470.         $params Helper::defaultSearchParams();
  471.         $params["search"]["residency"] = $country["cca2"];
  472.         $featuredHotels = [];
  473.         foreach ($results as $result){
  474.             $item["name"] = $result["name"];
  475.             if(!empty($result["images"]) && !empty($result["images"][0])){
  476.                 $item["image"] = str_replace('{size}','240x240'$result["images"][0]);
  477.             }
  478.             $item["region"] = $result["region"]["name"];
  479.             $params["search"]["location"] = $result["region"]["id"];
  480.             $item["link"] = $router->generate('app_detail_hotel_detail', ["id"=>$result["id"], $params]);
  481.             $featuredHotels[] = $item;
  482.         }
  483.         return $featuredHotels;
  484.     }
  485.     public function randomHotels($country){
  486.         /** @var Router $router */
  487.         $router $this->container->get('router');
  488.         $collection 'hotels_'.$this->request->getLocale();
  489.         $this->hm->select($collection);
  490.         $results $this->hm->findBy(['$and' =>[["reviews.rating" => ['$gt' => 5]], ["star_rating"=>[ '$gt' => 2]]]],100);
  491.         shuffle($results);
  492.         $params Helper::defaultSearchParams();
  493.         $params["search"]["residency"] = $country["cca2"];
  494.         $featuredHotels = [];
  495.         foreach ($results as $ind=>$result){
  496.             if($ind 4){
  497.                 break;
  498.             }
  499.             $item["name"] = $result["name"];
  500.             if(!empty($result["images"]) && !empty($result["images"][0])){
  501.                 $item["image"] = str_replace('{size}','240x240'$result["images"][0]);
  502.             }
  503.             $item["region"] = $result["region"]["name"];
  504.             $item["address"] = $result["address"];
  505.             $params["search"]["location"] = $result["region"]["id"];
  506.             $item["link"] = $router->generate('app_detail_hotel_detail', ["id"=>$result["id"], $params]);
  507.             $featuredHotels[] = $item;
  508.         }
  509.         return $featuredHotels;
  510.     }
  511.     private function getRequestParams(Request $request){
  512.         return array_merge($request->request->all(),$request->query->all());
  513.     }
  514.     public function hotelImages($images){
  515.         $resizedImages = [];
  516.         $sizes = [
  517.             'crop100' => '100x100',
  518.             'fit' => '1024x768',
  519.             'crop120' => '120x120',
  520.             'crop240' => '240x240',
  521.             'fit220' => 'x220',
  522.             'fit500' => 'x500',
  523.         ];
  524.         foreach ($sizes as $key=>$size){
  525.             $item = [];
  526.             foreach ($images as $image){
  527.                 if(empty($image)){
  528.                     continue;
  529.                 }
  530.                 $resized str_replace('{size}',$size$image);
  531.                 $item[] = $resized;
  532.             }
  533.             $resizedImages[$key] = $item;
  534.         }
  535.         return $resizedImages;
  536.     }
  537.     public function getHotelInfo($id$language){
  538.         $curl curl_init();
  539.         curl_setopt_array($curl, array(
  540.             CURLOPT_URL => 'https://api.worldota.net/api/b2b/v3/hotel/info/',
  541.             CURLOPT_USERPWD => $this->bag->get('zstd_user').":".$this->bag->get('zstd_pass'),
  542.             CURLOPT_RETURNTRANSFER => true,
  543.             CURLOPT_ENCODING => '',
  544.             CURLOPT_MAXREDIRS => 10,
  545.             CURLOPT_TIMEOUT => 0,
  546.             CURLOPT_FOLLOWLOCATION => true,
  547.             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  548.             CURLOPT_CUSTOMREQUEST => 'POST',
  549.             CURLOPT_POSTFIELDS =>'{
  550.     "id": "'.$id.'",
  551.     "language": "'.$language.'"
  552. }',
  553.             CURLOPT_HTTPHEADER => array(
  554.                 'Content-Type: application/json'
  555.             ),
  556.         ));
  557.         $response curl_exec($curl);
  558.         $res = [];
  559.         curl_close($curl);
  560.         $data json_decode($responsetrue);
  561.         if($data["status"] == "ok"){
  562.             $res $data["data"];
  563.         }
  564.         return $res;
  565.     }
  566. }