This package will get the full address information based on the zipcode and house number. Currently online dutch addresses are supported.
marshmallow/address-prefiller is a Laravel package for this package will get the full address information based on the zipcode and house number. currently online dutch addresses are supported..
It currently has 0 GitHub stars and 6.627 downloads on Packagist (latest version v2.3.0).
Install it with composer require marshmallow/address-prefiller.
Discover more Laravel packages by marshmallow
or browse all Laravel packages to compare alternatives.
Last updated

This package prefills address fields based on a provided zipcode and house number. It currently only supports Dutch addresses. You can use it in your custom applications, or use the ready-made field with Laravel Nova.
The address data is retrieved from the official open API provided by the Dutch government (PDOK Locatieserver), which should contain the latest information.
Install the package via Composer:
composer require marshmallow/address-prefiller
The service provider (Marshmallow\Zipcode\FieldServiceProvider) is auto-discovered by Laravel, so there is nothing else to register.
A custom Laravel Nova field is available which you can use. It works very similarly to the Laravel Place field. The difference is that this field does not talk to Algolia, but to the official open API provided by the Dutch government, which should contain the latest information.
use Marshmallow\Zipcode\Nova\Zipcode;
public function fields(Request $request)
{
return [
ID::make()->sortable(),
$this->addressFields(),
];
}
protected function addressFields()
{
return $this->merge([
Zipcode::make(__('Zipcode prefiller'), __('Zipcode'), __('Housenumber'))
/**
* Let the package know which columns are connected to
* the fields. The default values are commented after each
* function call. If your column names match these defaults,
* you don't need to call all these functions.
*/
->zipcode('zipcode') // default: zipcode
->housenumber('housenumber') // default: housenumber
->street('street') // default: street
->city('city') // default: city
->province('province') // default: province
->country('country') // default: country
->latitude('latitude') // default: latitude
->longitude('longitude'), // default: longitude
/**
* The fields below will all be prefilled with the collected
* data if we find a match on the submitted zipcode and house number.
*/
Hidden::make(__('Zipcode'), 'zipcode')->hideFromIndex(),
Hidden::make(__('Housenumber'), 'address_2')->hideFromIndex(),
Text::make(__('Street'), 'address_1')->hideFromIndex(),
Text::make(__('City'), 'city')->hideFromIndex(),
Text::make(__('Province'), 'province')->hideFromIndex(),
Country::make(__('Country'), 'country')->hideFromIndex(),
Text::make(__('Latitude'), 'latitude')->hideFromIndex(),
Text::make(__('Longitude'), 'longitude')->hideFromIndex(),
]);
}
The field exposes a fluent setter for each address attribute so you can map it to the column names used in your resource: zipcode(), housenumber(), street(), city(), province(), country(), latitude() and longitude().
We have provided an example of how you can use this functionality in your own application. We've currently only used this in the Nova setting, so if you're missing anything, please let us know!
use Marshmallow\Zipcode\Facades\Zipcode;
return Zipcode::get(
$request->zipcode,
$request->housenumber
);
You can map the returned address fields to your own keys by chaining the setter methods before calling get():
use Marshmallow\Zipcode\Facades\Zipcode;
return Zipcode::street('address_1')
->city('city')
->province('province')
->country('country')
->latitude('latitude')
->longitude('longitude')
->get($request->zipcode, $request->housenumber);
composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see the License File for more information.