/** * Returns the nearby restaurant activities of the user base on location * route: /activities/restaurant/near/{longitude}/{latitude}/{distance} * get user_id parameter to exclude current user data to show in teh activities * * @param $longitude * @param $latitude * @param $distance * @return response */ public function getNearRestaurantActivitiesAction($longitude, $latitude, $distance) { $viewer_id = Input::get('viewer_id', 0); $restaurant_ids = array(); $near_restaurant = Restaurants::getNearbyRestaurants($longitude, $latitude, $distance, CONSTANTS::RESTAURANTS_GET_NEARBY_PAGINATION_LIMIT); // get restaurant ids foreach ($near_restaurant as $restaurant) { $restaurant_ids[] = $restaurant->id; } $restaurant_activities = Activities::getRestaurantsActivities($restaurant_ids, $viewer_id); $activitiesArray = Activities::activitiesQueries($restaurant_activities); $page[KeyParser::current] = $restaurant_activities->currentPage(); $page[KeyParser::number] = $restaurant_activities->lastPage(); $json_return = array(KeyParser::data => $activitiesArray, KeyParser::page => $page); return response()->json($json_return); }
/** * Displays a list of nearby restaurants based on a specific cuisine * route: /restaurants/nearby-restaurant-cuisines/{longitude}/{latitude}/{distance}/{cuisine} * * @param $longitude * @param $latitude * @param $distance * @param $cuisine * @return Response */ public function nearbyRestaurantsCuisineAction($longitude, $latitude, $distance, $cuisine) { $current_page = Input::get('page', CONSTANTS::FIRST_PAGE); $category = Categories::getCuisineByName($cuisine); $restaurants = Restaurants::getNearbyRestaurants($longitude, $latitude, $distance, CONSTANTS::RESTAURANTS_GET_NEARBY_PAGINATION_LIMIT, $current_page, null, $category->id, null); $data = array(); foreach ($restaurants as $restaurant) { $data[] = array(KeyParser::restaurant => ModelFormatter::nearRestaurantFormat($restaurant), KeyParser::categories => Categories::getFormattedRestaurantCategories($restaurant->id)); } $page = array(KeyParser::current => $restaurants->currentPage(), KeyParser::number => $restaurants->lastPage()); $json_return = array(KeyParser::data => $data, KeyParser::page => $page); return response()->json($json_return); }