PHP code example of clevyr / laravel-geocoder

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

    

clevyr / laravel-geocoder example snippets


return [
    'adapter' => 'google',
    'test-adapter' => 'test',
    'test' => [
        'lat' => 35.4771302,
        'lng' => -97.5283204,
    ],
];

use Clevyr\LaravelGeocoder\LaravelGeocoder;

$coords = LaravelGeocoder::GetLatLngFromAddress(
    '123 Test Ln',
    null,
    'New York',
    'NY',
    '10001',
);

echo $coords;

// [
//     "lat" => 40.7607184,
//     "lng" => -73.9613766,
// ]

use Clevyr\LaravelGeocoder\Traits\Geocodable;

class MyModel extends Model
{
    use Geocodable;
}

$model = MyModel::find(1);
$coords = $model->getLatAndLong();

$model->name = 'New Name';
$model->addressIsDirty(); // false

$model->address_line_1 = '123 Foo Ln.';
$model->addressIsDirty(); // true

    // Override the postal_code property with something specific to this model
    public function getGeocoderPostalCodeAttribute()
    {
        return 'zip';
    }

public function getGeocoderAddressLine1Attribute();
public function getGeocoderAddressLine2Attribute();
public function getGeocoderCityAttribute();
public function getGeocoderStateAttribute();
public function getGeocoderPostalCodeAttribute();
public function getGeocoderCountryAttribute();
bash
php artisan vendor:publish --provider="Clevyr\LaravelGeocoder\LaravelGeocoderServiceProvider"
bash
composer analyse