/**
  * @param $token
  * @param $food_data
  * @param transpo
  * @return json response
  */
 public static function addFood($token, $food_data, $transpo)
 {
     //todo
     $response = self::resolveNewSegmentFromActivity($token, $transpo, $food_data);
     //        return $response;
     if ($response['err code'] == '403') {
         return $response;
     }
     // inline error response
     $current_iterinary = self::getUserCurrentIterinary($token);
     //        return $current_iterinary;s
     if ($current_iterinary['err'] == 'err') {
         return response()->json($current_iterinary, 403);
     }
     $day = self::getDiffInDays($token, $current_iterinary->id);
     $activity = new Activity();
     $activity->start_time = Carbon::now()->toTimeString();
     $activity->iterinary_id = $current_iterinary->id;
     $activity->day = $day;
     $eat = new Eat();
     $eat->place_name = $food_data['place_name'];
     $eat->lng = $food_data['lng'];
     $eat->lat = $food_data['lat'];
     $eat->tips = $food_data['review'];
     $eat->price = $food_data['price'];
     $eat->foursquare_id = !$food_data['foursquare_id'] ? null : $food_data['foursquare_id'];
     $foodcategory = FoursquareHelper::resolveFoodCategory($food_data['category']['cat_id']);
     if (isset($foodcategory['error_code'])) {
         return $foodcategory;
     }
     // returns error
     //        return response()->json($foodcategory['main_cat']);
     $eat->main_category_id = $foodcategory['main_cat'];
     $eat->sub_category_id = $foodcategory['sub_cat'];
     $pic = $food_data['category'];
     $eat->pic_url = $pic['prefix'] . 'bg_64' . $pic['suffix'];
     //        return response()->json($eat);
     $eat->save();
     $eat->activity()->save($activity);
     //        return $eat;
     self::updateIterinary($token);
     $iterinary = Iterinary::findOrFail($current_iterinary->id)->with('activities.typable')->first();
     return response()->json($eat, 200);
     //
     //        $current_iterinary = self::getUserCurrentIterinary($token);
     //        $day = self::getDiffInDays($token, $current_iterinary->id);
     //        $activity = new Activity();
     //        $activity->start_time = Carbon::now()->toTimeString();
     //        $activity->iterinary_id = $current_iterinary->id;
     //        $activity->day = $day;
     //        $eat = new Eat();
     //        $eat->place_name = $food_data['place_name'];
     //        $eat->lng = $food_data['lng'];
     //        $eat->lat = $food_data['lat'];
     //        $eat->tips = $food_data['review'];
     //        $eat->price = $food_data['price'];
     //
     //        $foodcategory = FoursquareHelper::resolveFoodCategory($food_data['category']['cat_id']);
     //
     ////        return response()->json($foodcategory['main_cat']);
     //        $eat->main_category_id = $foodcategory['main_cat'];
     //        $eat->sub_category_id = $foodcategory['sub_cat'];
     //        $pic = $food_data['category'];
     //        $eat->pic_url = $pic['prefix'] . '64' . $pic['suffix'];
     //
     //        self::resolveSegmentFromActivity($token);
     //
     //        $eat->save();
     //        $eat->activity()->save($activity);
     //
     //
     //        $iterinary = Iterinary::findOrFail($current_iterinary->id)
     //            ->with('activities.typable')
     //            ->first();
     //        return response()->json($iterinary, 200);
     //
     //        return response()->json($request);
 }
 public function testGeoLocation(Input $input)
 {
     $latitude = $input->get('latitude');
     $longitude = $input->get('longitude');
     $ll = $latitude . ',' . $longitude;
     $keyword = $input->get('keyword');
     //        $ip = $_SERVER['REMOTE_ADDR'];
     $data = Foursquare::call($keyword, $ll);
     $data = $data->response->venues;
     return view('results', compact('data'));
     //        $details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
     dd($data);
     //        $location = file_get_contents('http://freegeoip.net/json/'.$_SERVER['REMOTE_ADDR']);
     //        dd($ip,$details);
 }