PHP code example of zinapse / laralocate

1. Go to this page and download the library: Download zinapse/laralocate 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/ */

    

zinapse / laralocate example snippets




use Zinapse\LaraLocate\Models\City;

$city = City::first();            // Get any City object
$state = $city->state;            // Get this city's State object
$country = $city->country;        // Get this city's Country object

$zipcodes = $city->getPostalCodes(6); // ['type' => 'findNearbyPostalCodes', 'lat' => $city->lat, 'lng' => $city->long, 'radius' => 6, 'maxRows' => 5]



use Zinapse\LaraLocate\Models\State;

// Get all states from the country passed
$state = State::fromCountry('United States');
$code = $state->code;             // The state code
$cities = $state->cities;         // A collection of City objects from this state
$country = $state->country;       // This state's Country object



use Zinapse\LaraLocate\Models\Country;

$country = Country::where('name', 'United States')->first();
$states = $country->states;       // Get a collection of this country's State objects




use Zinapse\LaraLocate\Models\FeatureCode;

$code = FeatureCode::where('code', 'A')->first();
$examples = explode('|', $code->short_desc); // ['country', 'state', 'region]




use Zinapse\LaraLocate\Models\GeoNames;

$all_webhooks = GeoNames::GetWebhooks(); // returns an array: ['webhook name' => [
// Added helper functions so you don't have to remember all this, or pass arrays, etc
$search = GeoNames::GeoSearch('Alaska', 2); // ['type' => 'search', 'q' => 'Alaska', 'maxRows' => 2]