A service wrapper around postcodes.io with validation rule and macro
Via Composer
$ composer require juststeveking/laravel-postcodes
You can use the validation rule:
<?php
$this->validate($request, [
'postcode' => [
'required',
'string',
new Postcode()
]
]);
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
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);
}
}
Please see CHANGELOG for more information on what has changed recently.
$ composer test
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email juststevemcd@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.