Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($variable_search)
 {
     $variable_search = urldecode($variable_search);
     $resultDBArray = Place::select('place_id', 'place_name', 'place_city')->whereRaw("MATCH(place_name) AGAINST(? IN BOOLEAN MODE)", array($variable_search))->orderBy('views')->get();
     if (count($resultDBArray) > 0) {
         $resultJSON["success"] = "1";
         $resultJSON["items"] = $resultDBArray;
         for ($i = 0; $i < count($resultDBArray); $i++) {
             $place_id = $resultJSON["items"][$i]['place_id'];
             $city_id = $resultJSON["items"][$i]['place_city'];
             $resultDBImages = $this->getImages($place_id);
             $city_nameArray = $this->getCityName($city_id);
             $resultJSON["items"][$i]['place_city'] = $city_nameArray['city_name'];
             $resultJSON["items"][$i]['images'] = $resultDBImages;
         }
     } else {
         $resultJSON["success"] = "0";
     }
     echo json_encode($resultJSON);
 }
Example #2
0
 public function place($place_id = null)
 {
     $resultDBArray = Place::select('place_id', 'place_name', 'place_desc', 'place_city', 'picture')->where('place_id', '=', $place_id)->first();
     if (count($resultDBArray) > 0) {
         $resultJSON["success"] = "1";
         $resultJSON["item"] = $resultDBArray;
         $resultDBImages = $this->getImages($place_id);
         $locationArray = $this->getLocation($place_id);
         $city_nameArray = $this->getCityName($resultDBArray['place_city']);
         $pointsArray = $this->getPoints($place_id);
         $price = $this->getPrice($place_id);
         $resultJSON["item"]['place_city'] = $city_nameArray['city_name'];
         $resultJSON["item"]['longitude'] = $locationArray['longitude'];
         $resultJSON["item"]['latitude'] = $locationArray['latitude'];
         $resultJSON["item"]['images'] = $resultDBImages;
         $resultJSON["item"]['points'] = $pointsArray;
         $resultJSON["item"]['price'] = $price;
     } else {
         $resultJSON["success"] = "0";
     }
     echo json_encode($resultJSON);
 }
Example #3
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function filter($city = null, $rest = null, $catForApp = null)
 {
     $catForApp = urldecode($catForApp);
     $city = urldecode($city);
     $rest = urldecode($rest);
     $str = "любой";
     strnatcasecmp($rest, $str) == 0 ? $rest = null : false;
     strnatcasecmp($city, $str) == 0 ? $city = null : false;
     $rest != null ? $arrayPlaceId = $this->getPlaceIdByRestId($this->getRestId($rest)) : ($arrayPlaceId = null);
     $city != null ? $cityId = $this->getCityId($city) : ($cityId = null);
     if ($arrayPlaceId != null && $cityId != null) {
         if ($catForApp != null) {
             $resultDBArray = Place::select('place_id', 'place_name', 'place_city', 'picture')->whereIn('place_id', $arrayPlaceId)->where('cat_for_app_id', $catForApp)->with('location')->where('place_city', $cityId)->orderBy('views')->get();
         } else {
             $resultDBArray = Place::select('place_id', 'place_name', 'place_city', 'picture')->whereIn('place_id', $arrayPlaceId)->with('location')->where('place_city', $cityId)->orderBy('views')->get();
         }
     } else {
         if ($arrayPlaceId != null && $cityId == null) {
             if ($catForApp != null) {
                 $resultDBArray = Place::select('place_id', 'place_name', 'place_city', 'picture')->where('cat_for_app_id', $catForApp)->with('location')->whereIn('place_id', $arrayPlaceId)->orderBy('views')->get();
             } else {
                 $resultDBArray = Place::select('place_id', 'place_name', 'place_city', 'picture')->whereIn('place_id', $arrayPlaceId)->orderBy('views')->with('location')->get();
             }
         } else {
             if ($arrayPlaceId == null && $cityId != null) {
                 if ($catForApp != null) {
                     $resultDBArray = Place::select('place_id', 'place_name', 'place_city', 'picture')->where('cat_for_app_id', $catForApp)->with('location')->where('place_city', $cityId)->orderBy('views')->get();
                 } else {
                     $resultDBArray = Place::select('place_id', 'place_name', 'place_city', 'picture')->where('place_city', $cityId)->orderBy('views')->get();
                 }
             } else {
                 if ($catForApp != null) {
                     $resultDBArray = Place::select('place_id', 'place_name', 'place_city', 'picture')->where('cat_for_app_id', $catForApp)->with('location')->orderBy('views')->get();
                 } else {
                     $resultDBArray = Place::select('place_id', 'place_name', 'place_city', 'picture')->with('location')->orderBy('views')->get();
                 }
             }
         }
     }
     if (count($resultDBArray) > 0) {
         $resultJSON["success"] = "1";
         $resultJSON["items"] = $resultDBArray;
         for ($i = 0; $i < count($resultDBArray); $i++) {
             $place_id = $resultJSON["items"][$i]['place_id'];
             $city_id = $resultJSON["items"][$i]['place_city'];
             $resultDBImages = $this->getImages($place_id);
             $city_nameArray = $this->getCityName($city_id);
             $resultJSON["items"][$i]['place_city'] = $city_nameArray['city_name'];
             $resultJSON["items"][$i]['images'] = $resultDBImages;
         }
     } else {
         $resultJSON["success"] = "0";
     }
     echo json_encode($resultJSON);
 }
Example #4
0
 public function gide(Request $request = null)
 {
     if ($request->input) {
         $rest = urldecode($request->input('typerest'));
         $city = urldecode($request->input('town'));
         $str = "любой";
         strnatcasecmp($rest, $str) == 0 ? $rest = null : false;
         strnatcasecmp($city, $str) == 0 ? $city = null : false;
         $rest != null ? $arrayPlaceId = $this->getPlaceIdByRestId($this->getRestId($rest)) : ($arrayPlaceId = null);
         $city != null ? $cityId = $this->getCityId($city) : ($cityId = null);
         if ($arrayPlaceId != null && $cityId != null) {
             $resultDBArray = Place::select('place_id', 'place_name', 'picture')->where('cat_for_app_id', '=', '4')->with('location')->whereIn('place_id', $arrayPlaceId)->where('place_city', $cityId)->get();
         } else {
             if ($arrayPlaceId != null && $cityId == null) {
                 $resultDBArray = Place::select('place_id', 'place_name', 'picture')->where('cat_for_app_id', '=', '4')->with('location')->whereIn('place_id', $arrayPlaceId)->get();
             } else {
                 if ($arrayPlaceId == null && $cityId != null) {
                     $resultDBArray = Place::select('place_id', 'place_name', 'picture')->where('cat_for_app_id', '=', '4')->with('location')->where('place_city', $cityId)->get();
                 } else {
                     $resultDBArray = Place::select('place_id', 'place_name', 'picture')->where('cat_for_app_id', '=', '4')->with('location')->get();
                 }
             }
         }
     } else {
         $resultDBArray = Place::select('place_id', 'place_name', 'picture')->where('cat_for_app_id', '=', '4')->with('location')->get();
     }
     if (count($resultDBArray) > 0) {
         $content["success"] = "Экскурсии";
         $content["check"][0] = "Культура и отдых";
         $content["check"][1] = "Где поспать";
         $content["check"][2] = "Где поспать";
         $resultJSON["items"] = $resultDBArray;
         for ($i = 0; $i < count($resultDBArray); $i++) {
             $lng = $resultJSON["items"][$i]['location']['longitude'];
             $lat = $resultJSON["items"][$i]['location']['latitude'];
             $resultJSON["items"][$i]['longitude'] = $lng;
             $resultJSON["items"][$i]['latitude'] = $lat;
             unset($resultJSON["items"][$i]['location']);
         }
     } else {
         $resultJSON["success"] = "0";
     }
     $cities = City::select('city_name')->distinct()->get();
     $rests = Rest::select('rest_type')->distinct()->get();
     $content['cities'] = $cities;
     $content['rests'] = $rests;
     $content['dbArray'] = $resultDBArray;
     $content['JSONarray'] = json_encode($resultJSON);
     return view('filter', $content);
 }