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
{{ message }}
This repository was archived by the owner on Oct 4, 2022. It is now read-only.
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 Laravelrelated wiring code for [vat.php](https://github.com/dannyvankooten/vat.php), helping you deal with VAT legislation for businesses based in Europe.
8
8
9
9
- Fetch (historical) VAT rates for any European member state using [jsonvat.com](https://github.com/adamcooke/vat-rates)
10
10
- 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.
25
25
26
26
## Usage
27
27
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:
29
34
30
35
```php
31
36
use DvK\Laravel\Vat\Facades\Rates;
@@ -51,6 +56,52 @@ Countries::ip('8.8.8.8'); // US
51
56
52
57
By default, VAT rates are cached for 24 hours using the default cache driver.
53
58
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.
0 commit comments