PHP code example of illuma-law / laravel-places-scout
1. Go to this page and download the library: Download illuma-law/laravel-places-scout library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
illuma-law / laravel-places-scout example snippets
return [
/**
* Your Google Places API Key.
* Obtain an API key from the Google Cloud Console:
* https://console.cloud.google.com/google/maps-apis/credentials
*/
'api_key' => env('GOOGLE_PLACES_API_KEY'),
];
use IllumaLaw\PlacesScout\Facades\PlacesScout;
// Basic text search
$response = PlacesScout::textSearch('Law firms in New York');
if ($response) {
foreach ($response->results as $result) {
echo $result->name; // 'Smith & Associates'
echo $result->placeId; // 'ChIJ...'
echo $result->formattedAddress; // '123 Main St, New York, NY'
echo $result->latitude; // 40.7128
echo $result->longitude; // -74.0060
echo $result->rating; // 4.8
}
// Handle pagination using the nextPageToken
if ($response->nextPageToken) {
$nextPage = PlacesScout::textSearch('Law firms in New York', $response->nextPageToken);
}
}
use IllumaLaw\PlacesScout\Facades\PlacesScout;
$userApiKey = $user->settings->google_api_key;
// Override API key for this specific request
$response = PlacesScout::withApiKey($userApiKey)->textSearch('Restaurants in Paris');
namespace App\Http\Controllers;
use IllumaLaw\PlacesScout\PlacesScoutService;
class LocationController extends Controller
{
public function __construct(
private PlacesScoutService $placesScout
) {}
public function search(string $query)
{
$results = $this->placesScout->textSearch($query);
return response()->json($results);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.