PHP code example of cyber-duck / laravel-address-finder

1. Go to this page and download the library: Download cyber-duck/laravel-address-finder 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/ */

    

cyber-duck / laravel-address-finder example snippets


// $query: The search string
// $countryCode: The country code to search for addresses within
// $groupId: Results can have children, if this is the case you can retrieve the results children by passing the ID
Address::suggestions($query, $countryCode, $groupId);

CyberDuck\AddressFinder\Facades\Address::suggestions('EC1N', 'GB', null)->get();

/*
[
 [
   "id" => "1",
   "text" => "London, United Kingdom, EC1N 8TB - 2 Addresses",
   "has_children" => true,
 ],
]
 */


CyberDuck\AddressFinder\Facades\Address::suggestions('EC1N', 'GB', 1)->get();

/*
[
    [
     "id" => "2",
     "text" => "1 Greville Street - Greville Street London, 1, United Kingdom, EC1N 8TB",
     "has_children" => false,
    ],
    [
      "id" => "3",
      "text" => "2 Greville Street - Greville Street London, 2, United Kingdom, EC1N 8TB",
      "has_children" => false,
    ],
]
 */

// $addressId: The id of the address found from the suggestions method
Address::details($addressId);

CyberDuck\AddressFinder\Facades\Address::details('2')->get();

/*
[
     "postal_code" => "EC1N 8TB",
     "province_code" => "",
     "state" => "",
     "city" => "London",
     "address_line_1" => "Greville Street",
     "address_line_2" => "1",
     "address_line_3" => "",
]
*/

// $postcode: The postcode to use to search with
Address::postzon($postcode);

CyberDuck\AddressFinder\Facades\Address::postzon('N7 7PH')->get();

/*
[
    'Easting' => 530915,
    'Northing' => 186310,
    'Latitude' => 51.560487,
    'Longitude' => -0.112808,
    'OsGrid' => 'TQ 30915 86310',
    'CountryCode' => '921',
    'NewCountryCode' => 'E92000001',
    'CountryName' => 'England',
    'CountyCode' => '',
    'NewCountyCode' => 'E99999999',
    'CountyName' => '(pseudo) England (UA/MD/LB)',
    'DistrictCode' => '',
    'NewDistrictCode' => 'E09000019',
    'DistrictName' => 'Islington',
    'WardCode' => '00AUGC',
    'NewWardCode' => 'E05013703',
    'WardName' => '',
    'NhsShaCode' => 'Q36',
    'NewNhsShaCode' => '',
    'NhsShaName' => 'London',
    'NhsPctCode' => '',
    'NewNhsPctCode' => 'E16000048',
    'NhsPctName' => 'Islington',
    'LeaCode' => '',
    'LeaName' => '',
    'GovernmentOfficeCode' => 'H',
    'GovernmentOfficeName' => 'London',
    'WestminsterConstituencyCode' => 'C36',
    'WestminsterConstituencyName' => 'Islington North',
    'WestminsterMP' => 'Jeremy Corbyn',
    'WestminsterParty' => 'Labour',
    'WestminsterConstituencyCode2010' => 'C36',
    'WestminsterConstituencyName2010' => 'Islington North',
    'LSOACode' => 'E01002730',
    'LSOAName' => 'Islington 007A',
    'MSOACode' => 'E02000560',
    'MSOAName' => 'Islington 007',
    'CCGCode' => '93C',
    'CCGName' => 'NHS North Central London CCG',
    'CCGAreaCode' => '',
    'CCGAreaName' => '',
    'CCGRegionCode' => '',
    'CCGRegionName' => '',
]
*/