All Projects → JustSteveKing → LaravelPostcodes

JustSteveKing / LaravelPostcodes

Licence: MIT license
A service wrapper around postcodes.io

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to LaravelPostcodes

Laravel Geo Routes
GeoLocation restricted routes for Laravel
Stars: ✭ 110 (+50.68%)
Mutual labels:  geolocation, laravel-package
geolocation
A laravel integration for using the IPInfoDB and Ip2Location services
Stars: ✭ 38 (-47.95%)
Mutual labels:  geolocation, laravel-package
Timezonefinder
fast python package for finding the timezone of any point on earth (coordinates) offline
Stars: ✭ 242 (+231.51%)
Mutual labels:  geolocation
ipinfodb-php
PHP library to query free IPInfoDB API service.
Stars: ✭ 15 (-79.45%)
Mutual labels:  geolocation
go
Official Golang client library for the ipdata API
Stars: ✭ 21 (-71.23%)
Mutual labels:  geolocation
I See You
ISeeYou is a Bash and Javascript tool to find the exact location of the users during social engineering or phishing engagements. Using exact location coordinates an attacker can perform preliminary reconnaissance which will help them in performing further targeted attacks.
Stars: ✭ 246 (+236.99%)
Mutual labels:  geolocation
Instagram-for-PHP
PHP SDK for Instagram API
Stars: ✭ 82 (+12.33%)
Mutual labels:  laravel-package
Clavin
CLAVIN (Cartographic Location And Vicinity INdexer) is an open source software package for document geoparsing and georesolution that employs context-based geographic entity resolution.
Stars: ✭ 237 (+224.66%)
Mutual labels:  geolocation
blurhash
A PHP implementation of BlurHash with Laravel integration.
Stars: ✭ 46 (-36.99%)
Mutual labels:  laravel-package
GoGoCarto
This repo has been moved to https://gitlab.adullact.net/pixelhumain/GoGoCarto since 17/12/2018
Stars: ✭ 43 (-41.1%)
Mutual labels:  geolocation
boilerplate
Laravel AdminLTE 3 Boilerplate package with blade components, users, roles and permissions management
Stars: ✭ 167 (+128.77%)
Mutual labels:  laravel-package
google-maps-places-geolocation-for-your-ionic-app
Ionic example app of how to add Google maps, places, geolocation and related features into an Ionic Framework app.
Stars: ✭ 13 (-82.19%)
Mutual labels:  geolocation
Cities.json
Cities of the world in Json, based on GeoNames Gazetteer
Stars: ✭ 251 (+243.84%)
Mutual labels:  geolocation
radar-sdk-android
Android SDK for Radar, the leading geofencing and location tracking platform
Stars: ✭ 57 (-21.92%)
Mutual labels:  geolocation
Asn
ASN / RPKI validity / BGP stats / IPv4v6 / Prefix / URL / ASPath / Organization / IP reputation and geolocation lookup tool / Traceroute server
Stars: ✭ 242 (+231.51%)
Mutual labels:  geolocation
exploring-my-neighborhood
track all your moves and visualize them!
Stars: ✭ 16 (-78.08%)
Mutual labels:  geolocation
React Geolocation
🌎🛰 Declarative geolocation for React
Stars: ✭ 238 (+226.03%)
Mutual labels:  geolocation
emapic
Open source repository with the source code of the geolocated surveys engine Emapic, developed by the laboratory CartoLAB of the Universidade da Coruña.
Stars: ✭ 14 (-80.82%)
Mutual labels:  geolocation
nova-rating-field
A Star rating field to use in your Laravel Nova apps.
Stars: ✭ 42 (-42.47%)
Mutual labels:  laravel-package
laravel-packages
Useful packages for Laravel projects
Stars: ✭ 22 (-69.86%)
Mutual labels:  laravel-package

LaravelPostcodes

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

A service wrapper around postcodes.io with validation rule and macro

Install

Via Composer

$ composer require juststeveking/laravel-postcodes

After installation, merge configuration for services using:

$ php artisan vendor:publish --provider="JustSteveKing\LaravelPostcodes\PostcodesServiceProvider"

If, for some reason, this doesn't work please use the following steps:

  • Add the following into the config/services.php configuration file:
<?php

'postcodes' => [
    'url' => env('POSTCODES_URL', 'https://api.postcodes.io/')
],
  • Add POSTCODES_URL to your .env file and add https://api.postcodes.io/ as the value.

Basic Usage

You can use the validation rule:

<?php

$this->validate($request, [
    'postcode' => [
        'required',
        'string',
        new Postcode(resolve(PostcodeService::class))
    ]
]);

Or you can use the validation Macro:

$this->validate($request, [
    'postcode' => [
        'required',
        'string',
        Rule::postcode()
    ]
]);

If you want to interact with the service itself:

<?php 

use JustSteveKing\LaravelPostcodes\Service\PostcodeService;

class SomeController extends Controller
{
    protected $postcodes;

    public function __construct(PostcodeService $service)
    {
        $this->postcodes = $service;
    }

    public function store(Request $request)
    {
        // validation using example above
        $location = $this->postcodes->getPostcode($request->postcode);
    }
}

Or use the facade:

<?php 

class SomeController extends Controller
{
    public function store(Request $request)
    {
        // validation using example above
        $location = Postcode::getPostcode($request->postcode);
    }
}

Validate

<?php

$service = resolve(PostcodeService::class);

$service->validate('AB10 1AB');

// You can also use the facade:
Postcode::validate('AB10 1AB');

Validate Postcode

<?php

$service = resolve(PostcodeService::class);

$service->validate('AB10 1AB');

// You can also use the facade:
Postcode::validate('AB10 1AB');

Get Postcode information

<?php

$service = resolve(PostcodeService::class);

$service->getPostcode('AB10 1AB');

// You can also use the facade:
Postcode::getPostcode('AB10 1AB');

Bulk Lookup Postcodes

<?php

$service = resolve(PostcodeService::class);

$service->getPostcodes([
    'AB10 1AB',
    'AB10 1AF',
    'AB10 1AG',
]);

// You can also use the facade:
Postcode::getPostcodes([
    'AB10 1AB',
    'AB10 1AF',
    'AB10 1AG',
]);

Get nearest postcodes for a given longitude & latitude

<?php

$service = resolve(PostcodeService::class);

$service->nearestPostcodesForGivenLngAndLat(
    0.629806,
    51.792326
);

// You can also use the facade:
Postcode::nearestPostcodesForGivenLngAndLat(
    0.629806,
    51.792326
);

Nearest postcodes for postcode

<?php

$service = resolve(PostcodeService::class);

$service->nearest('AB10 1AB');

// You can also use the facade:
Postcode::nearest('AB10 1AB');

Autocomplete a postcode partial

<?php

$service = resolve(PostcodeService::class);

$service->autocomplete('AB10');

// You can also use the facade:
Postcode::autocomplete('AB10');

Query for postcode

<?php

$service = resolve(PostcodeService::class);

$service->query('AB10 1AB');

// You can also use the facade:
Postcode::query('AB10 1AB');

Lookup terminated postcode

<?php

$service = resolve(PostcodeService::class);

$service->getTerminatedPostcode('AB1 0AA');

// You can also use the facade:
Postcode::getTerminatedPostcode('AB1 0AA');

Lookup Outward Code

<?php

$service = resolve(PostcodeService::class);

$service->getOutwardCode('N11');

// You can also use the facade:
Postcode::getOutwardCode('N11');

Nearest outward code for outward code

<?php

$service = resolve(PostcodeService::class);

$limit = 80; // Limit needs to be less than 100
$radius = 15000; // Radius needs to be less than 25000
$service->getNearestOutwardCode('N11', $limit, $radius);

// You can also use the facade:
Postcode::getNearestOutwardCode('N11', $limit, $radius);

Get nearest outward codes for a given longitude & latitude

<?php

$service = resolve(PostcodeService::class);

$service->nearestOutwardCodesForGivenLngAndLat(
    0.629806,
    51.792326
);

// You can also use the facade:
Postcode::nearestOutwardCodesForGivenLngAndLat(
    0.629806,
    51.792326
);

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].