LaravelPackages.net
Acme Inc.
Toggle sidebar
madeitbelgium/vat

PHP VAT Library

448
0
1.7.0
About madeitbelgium/vat

madeitbelgium/vat is a Laravel package for php vat library. It currently has 0 GitHub stars and 448 downloads on Packagist (latest version 1.7.0). Install it with composer require madeitbelgium/vat. Discover more Laravel packages by madeitbelgium or browse all Laravel packages to compare alternatives.

Last updated

PHP VAT Library

Build Status Coverage Status Latest Stable Version Latest Unstable Version Total Downloads License

Installation

Require this package in your composer.json and update composer.

"madeitbelgium/vat": "^1.6"

Or

composer require madeitbelgium/vat

After updating composer, add the ServiceProvider to the providers array in config/app.php

MadeITBelgium\Vat\ServiceProvider\Vat::class,

You can use the facade for shorter code. Add this to your aliases:

'Vat' => MadeITBelgium\Vat\Facade\Vat::class,

Documentation

Validation

$vatnr = "BE....";
$vat = new Vat($vatnr);
if($vat->isVatValid()) {
    echo "VAT is valid!";
}

laravel validation

$this->validate($request, ['vatnumber' => 'vat']);

When the service is down a ServiceUnavailableException exception is thrown. To allow the validation to succeed when the service is down you can add an option with the default value when to the validation.

$this->validate($request, ['vatnumber' => 'vat:true']);

Format (Not working)

$vatnr = "BE....";
$vat = new Vat($vatnr);
echo $vat->vatFormat();

Genearte OGM

$generator = new Vat;
echo $generator->generateOGM(1); //Output: 000000000101
echo $generator->generateOGM(1, "111"); //Output: 111000000195
echo $generator->generateOGM(2, "333", true); //Output: 333/0000/00290

Parse data

use MadeITBelgium\Vat\Facade\Vat;
$data = Vat::setVat($vatNr)->parse();
dd($data);

/*
countryCode: "",
valid: true,
name: "",
zipcode: "",
city: "",
street: "",
address: "",
*/

The complete documentation can be found at: http://www.madeitbelgium.org/my-projects/php-vat-library/

Support

Support github or mail: [email protected]

Contributing

Please try to follow the psr-2 coding style guide. http://www.php-fig.org/psr/psr-2/

License

This package is licensed under LGPL. You are free to use it in personal and commercial projects. The code can be forked and modified, but the original copyright author should always be included!

Star History Chart