Laravel Simple VAT
Laravel Simple VAT is a small library to check format of European VAT number., (*1)
It's mainly a curated version of the Laravel VAT package,
removing the SOAP call for existence., (*2)
Installation
Simply require the project using Composer:, (*3)
$ composer require hantless/simple-vat
Once Simple VAT is installed, you need to register the service provider. Open up config/app.php and add the following to
the providers key., (*4)
Hantless\SimpleVat\SimplevatServiceProvider::class
Or if you're using Laravel 5.5+, it should auto discover the package., (*5)
Usage
Use the validation rule "vat_format" in your formRequest:, (*6)
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'vatnumberfield' => 'vat_format',
];
}
or in your validator:, (*7)
public function store(Request $request)
{
$validator = Validator::make($request->all(), [
'vatnumberfield' => 'vat_format',
]);
if ($validator->fails()) {
// redirect ... display error
}
// store entity...
}
Add the error message in your translation files (resources/lang/{lang}/validation.php), (*8)
'vat_format' => 'The :attribute do not seem to be a valid VAT number',
License
Laravel Simple VAT is licensed under The MIT License(MIT)., (*9)