The Reviews class is a part of the Designbycode namespace and is used to fetch reviews, rating, and user ratings total of a place using the Google Places API. It requires a Google Maps API key and a Google Maps place ID to make requests.
This package provides a simple and easy-to-use interface for fetching place details from the Google Maps Place Details API.
If you want to fetch more reviews, please use the Google Maps Place Search API
To install the package, use composer:
composer require designbycode/google-maps-place-details
To use the package, you need to provide a Google Maps API key and a place ID:
use Designbycode\GoogleMapsPlaceDetails\PlaceDetails;
$placeDetails = new PlaceDetails('YOUR_API_KEY', 'YOUR_PLACE_ID');
You can then fetch the full result set from the Google Maps API:
$results = $placeDetails->getResults();
Or you can fetch specific data, such as reviews, rating, and user ratings total:
$reviews = $placeDetails->getReviews();
$rating = $placeDetails->getRating();
$userRatingTotal = $placeDetails->getUserRatingTotal();
The package supports the following fields:
- reviews
- rating
- user_ratings_total
$placeDetails = new PlaceDetails('YOUR_API_KEY', 'YOUR_PLACE_ID');
The Results
class is responsible for handling the results of a Google Maps Place Details API request. It provides the following methods:
reviews()
: Returns an array of reviews from the API response.rating()
: Returns the rating from the API response, or null if not present.userRatingsTotal()
: Returns the total number of user ratings from the API response, or null if not present.
$placeDetails = new PlaceDetails('YOUR_API_KEY', 'YOUR_PLACE_ID');
$placeDetails->getResults()->reviews();
The Field enum class is used to define the fields that can be fetched from the Google Maps Place Details API. It supports the following fields:
- reviews
- rating
- user_ratings_total
composer test
Please see CHANGELOG for more information on what has changed recently.
Contributions are welcome! Please submit a pull request with your changes. Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.