Downloads
Stars
Version
This package will prefill address field based on a provided zipcode and housenumber. This currently only supports Dutch addresses. This can be used in your custom applications or you can use it with Laravel Nova.
Install the package in a Laravel project via Composer.
# Install the package
composer require marshmallow/address-prefiller
There is a custom Laravel Nova field available which you can use. This works very simular to the Laravel Place field. The difference is that this field will not talk to Algolia but to the official open api provided by the dutch goverment which should contain all the latest information.
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. Is your column names match these defaults,
* you don't need to call all these functions.
*/
->zipcode('zipcode')
->housenumber('address_2')
->street('address_1')
->city('city')
->province('province')
->country('country')
->latitude('latitude')
->longitude('longitude'),
/**
* The field below will all be prefilled with the collected
* data if we find a match on the submitted zipcode and housenumber.
*/
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(),
]);
}
We have provided an example on 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
);
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 License File for more information.