Laravel Postcodes is a package by Steve McDougall that provides a validation rule and macro for validating post codes. The package uses the postcodes.io service—a free and open-source API—for looking up geocoded UK postcodes.
There are three ways to interact with postcodes using this package. First, you can use the provided validation rule:
use JustSteveKing\LaravelPostcodes\Rules\Postcode; $this->validate($request, [ ‘postcode’ => [ ‘required’, ‘string’, new Postcode() ] ]);
Second, you can use the provided macro:
$this->validate($request, [ ‘postcode’ => [ ‘required’, ‘string’, Rule::postcode() ] ]);
Third, this package defines a service for interacting with the API directly:
use JustSteveKing\LaravelPostcodes\Service\PostcodeService; app(PostcodeService::class)->getPostcode($postcode);
You can learn more about this package, get full installation instructions, and view the source code on GitHub at JustSteveKing/LaravelPostcodes.
Filed in: News
Join the weekly newsletter and never miss out on new tips, tutorials, and more.
- PHP Data Engineer
- Software Developer
Remote (US & Canada)
- Backend Software Engineer
Remote (UTC +/- 5)
Remote (Overlap w/ Continental US Time Zones)
- Senior Backend Engineer
- Senior Laravel Developer
- Full-Stack Developer (JS - Vue.js, PHP - Laravel)
US Remote / Telecommute
Laravel Mix Preload
Laravel Mix Preload is a Laravel package by Sebastian De Deyne and Spatie that adds preload and prefetch links based…
Prompt Users to Login When they Have an Expired Session with the isAuth Package
Laravel IsAuth is a Laravel package by Emre Dipi that provides control to check if a user session is dead before subm…