Skip to content
This repository was archived by the owner on Oct 4, 2022. It is now read-only.

Commit 6988b78

Browse files
update readme
1 parent 4ed4df0 commit 6988b78

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

README.md

+53-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Laravel VAT
44
<a href="https://travis-ci.org/dannyvankooten/laravel-vat"><img src="https://img.shields.io/travis/dannyvankooten/laravel-vat/master.svg?style=flat-square" alt="Build Status"></img></a>
55
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square" alt="Software License"></img></a>
66

7-
laravel-vat is a Laravel package that contains the Laravel-related wiring code for [vat.php](https://github.com/dannyvankooten/vat.php), helping you deal with VAT for businesses based in Europe.
7+
laravel-vat is a package that contains the Laravel related wiring code for [vat.php](https://github.com/dannyvankooten/vat.php), helping you deal with VAT legislation for businesses based in Europe.
88

99
- Fetch (historical) VAT rates for any European member state using [jsonvat.com](https://github.com/adamcooke/vat-rates)
1010
- Validate VAT numbers (by format, [existence](http://ec.europa.eu/taxation_customs/vies/) or both)
@@ -25,7 +25,12 @@ The package will automatically register itself.
2525

2626
## Usage
2727

28-
If you registered the facades then using an instance of the classes is as easy as this:
28+
Check out the [vat.php README](https://github.com/dannyvankooten/vat.php) for general usage of this package.
29+
30+
31+
#### Facades
32+
33+
Using facades, retrieving an instance of the classes provided by vat.php is easy:
2934

3035
```php
3136
use DvK\Laravel\Vat\Facades\Rates;
@@ -51,6 +56,52 @@ Countries::ip('8.8.8.8'); // US
5156

5257
By default, VAT rates are cached for 24 hours using the default cache driver.
5358

59+
60+
#### Validation
61+
62+
The package registers two new validation rules.
63+
64+
**vat_number**
65+
66+
The field under validation must be a valid and existing VAT number.
67+
68+
**country_code**
69+
70+
The field under validation must be a valid ISO-3316 alpha-2 country code.
71+
72+
```php
73+
use Illuminate\Http\Request;
74+
75+
class Controller {
76+
77+
public function foo(Request $request)
78+
{
79+
$request->validate([
80+
'vat_number_field' => ['vat_number'],
81+
'country_code_field' => [ 'country_code' ],
82+
]);
83+
}
84+
}
85+
```
86+
87+
Alternatively, you can also use the `Rule` objects directly.
88+
89+
```php
90+
use Illuminate\Http\Request;
91+
use DvK\Laravel\Vat\Rules;
92+
93+
class Controller {
94+
95+
public function foo(Request $request)
96+
{
97+
$request->validate([
98+
'vat_number_field' => [ new Rules\VatNumber() ],
99+
'country_code_field' => [ new Rules\Country() ],
100+
]);
101+
}
102+
}
103+
```
104+
54105
## License
55106

56107
[MIT licensed](LICENSE).

0 commit comments

Comments
 (0)