You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://packagist.org/packages/marshmallow/address-prefiller)
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.
11
+
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.
13
12
14
-
## Installation
13
+
The address data is retrieved from the official open API provided by the Dutch government (PDOK Locatieserver), which should contain the latest information.
15
14
16
-
### Installing the package via Composer
15
+
##Installation
17
16
18
-
Install the package in a Laravel project via Composer.
17
+
Install the package via Composer:
19
18
20
19
```bash
21
-
# Install the package
22
20
composer require marshmallow/address-prefiller
23
21
```
24
22
25
-
### Usage in Nova
23
+
The service provider (`Marshmallow\Zipcode\FieldServiceProvider`) is auto-discovered by Laravel, so there is nothing else to register.
24
+
25
+
## Usage in Nova
26
26
27
-
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.
27
+
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.
28
28
29
29
```php
30
+
use Marshmallow\Zipcode\Nova\Zipcode;
31
+
30
32
public function fields(Request $request)
31
33
{
32
34
return [
@@ -42,21 +44,21 @@ protected function addressFields()
42
44
/**
43
45
* Let the package know which columns are connected to
44
46
* the fields. The default values are commented after each
45
-
* function call. Is your column names match these defaults,
47
+
* function call. If your column names match these defaults,
@@ -70,12 +72,13 @@ protected function addressFields()
70
72
}
71
73
```
72
74
73
-
### Usage manualy
75
+
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()`.
74
76
75
-
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!
77
+
## Usage manually
76
78
77
-
```php
79
+
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!
78
80
81
+
```php
79
82
use Marshmallow\Zipcode\Facades\Zipcode;
80
83
81
84
return Zipcode::get(
@@ -84,20 +87,34 @@ return Zipcode::get(
84
87
);
85
88
```
86
89
90
+
You can map the returned address fields to your own keys by chaining the setter methods before calling `get()`:
91
+
92
+
```php
93
+
use Marshmallow\Zipcode\Facades\Zipcode;
94
+
95
+
return Zipcode::street('address_1')
96
+
->city('city')
97
+
->province('province')
98
+
->country('country')
99
+
->latitude('latitude')
100
+
->longitude('longitude')
101
+
->get($request->zipcode, $request->housenumber);
102
+
```
103
+
87
104
## Testing
88
105
89
106
```bash
90
107
composer test
91
108
```
92
109
93
-
## Security
110
+
## Security Vulnerabilities
94
111
95
112
If you discover any security related issues, please email stef@marshmallow.dev instead of using the issue tracker.
0 commit comments