Skip to content

Commit 2c9af59

Browse files
authored
Merge pull request #60 from marshmallow-packages/docs/readme-refresh
docs: refresh README
2 parents b534d21 + bba81a7 commit 2c9af59

1 file changed

Lines changed: 48 additions & 31 deletions

File tree

README.md

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
# Laravel Address Prefiller
2-
31
![alt text](https://marshmallow.dev/cdn/media/logo-red-237x46.png "marshmallow.")
42

5-
# Nova Translatable
3+
# Laravel Address Prefiller
64

7-
[![Version](https://img.shields.io/packagist/v/marshmallow/address-prefiller)](https://github.com/marshmallow-packages/address-prefiller)
8-
[![Downloads](https://shields.io/packagist/dt/marshmallow/address-prefiller)](https://github.com/marshmallow-packages/address-prefiller)
9-
[![Issues](https://img.shields.io/github/issues/marshmallow-packages/address-prefiller)](https://github.com/marshmallow-packages/address-prefiller)
10-
[![Licence](https://img.shields.io/github/license/marshmallow-packages/address-prefiller)](https://github.com/marshmallow-packages/address-prefiller)
5+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/marshmallow/address-prefiller.svg?style=flat-square)](https://packagist.org/packages/marshmallow/address-prefiller)
6+
[![Tests](https://img.shields.io/github/actions/workflow/status/marshmallow-packages/address-prefiller/php-syntax-checker.yml?branch=main&label=tests&style=flat-square)](https://github.com/marshmallow-packages/address-prefiller/actions/workflows/php-syntax-checker.yml)
7+
[![Total Downloads](https://img.shields.io/packagist/dt/marshmallow/address-prefiller.svg?style=flat-square)](https://packagist.org/packages/marshmallow/address-prefiller)
8+
[![Issues](https://img.shields.io/github/issues/marshmallow-packages/address-prefiller)](https://github.com/marshmallow-packages/address-prefiller/issues)
9+
[![License](https://img.shields.io/github/license/marshmallow-packages/address-prefiller)](https://github.com/marshmallow-packages/address-prefiller/blob/main/LICENSE.md)
1110

12-
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.
1312

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.
1514

16-
### Installing the package via Composer
15+
## Installation
1716

18-
Install the package in a Laravel project via Composer.
17+
Install the package via Composer:
1918

2019
```bash
21-
# Install the package
2220
composer require marshmallow/address-prefiller
2321
```
2422

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
2626

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.
2828

2929
```php
30+
use Marshmallow\Zipcode\Nova\Zipcode;
31+
3032
public function fields(Request $request)
3133
{
3234
return [
@@ -42,21 +44,21 @@ protected function addressFields()
4244
/**
4345
* Let the package know which columns are connected to
4446
* 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,
4648
* you don't need to call all these functions.
4749
*/
48-
->zipcode('zipcode')
49-
->housenumber('address_2')
50-
->street('address_1')
51-
->city('city')
52-
->province('province')
53-
->country('country')
54-
->latitude('latitude')
55-
->longitude('longitude'),
50+
->zipcode('zipcode') // default: zipcode
51+
->housenumber('housenumber') // default: housenumber
52+
->street('street') // default: street
53+
->city('city') // default: city
54+
->province('province') // default: province
55+
->country('country') // default: country
56+
->latitude('latitude') // default: latitude
57+
->longitude('longitude'), // default: longitude
5658

5759
/**
58-
* The field below will all be prefilled with the collected
59-
* data if we find a match on the submitted zipcode and housenumber.
60+
* The fields below will all be prefilled with the collected
61+
* data if we find a match on the submitted zipcode and house number.
6062
*/
6163
Hidden::make(__('Zipcode'), 'zipcode')->hideFromIndex(),
6264
Hidden::make(__('Housenumber'), 'address_2')->hideFromIndex(),
@@ -70,12 +72,13 @@ protected function addressFields()
7072
}
7173
```
7274

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()`.
7476

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
7678

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!
7880

81+
```php
7982
use Marshmallow\Zipcode\Facades\Zipcode;
8083

8184
return Zipcode::get(
@@ -84,20 +87,34 @@ return Zipcode::get(
8487
);
8588
```
8689

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+
87104
## Testing
88105

89106
```bash
90107
composer test
91108
```
92109

93-
## Security
110+
## Security Vulnerabilities
94111

95112
If you discover any security related issues, please email stef@marshmallow.dev instead of using the issue tracker.
96113

97114
## Credits
98115

99-
- [All Contributors](../../contributors)
116+
- [All Contributors](https://github.com/marshmallow-packages/address-prefiller/contributors)
100117

101118
## License
102119

103-
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
120+
The MIT License (MIT). Please see the [License File](LICENSE.md) for more information.

0 commit comments

Comments
 (0)