kfoobar/laravel-euro-vat
最新稳定版本:v1.0.1
Composer 安装命令:
composer require kfoobar/laravel-euro-vat
包简介
A Laravel package for Euro VAT validation
README 文档
README
A Laravel package for validating EU VAT numbers, including local format validation and online validation against the EU VIES API.
Installation
Install the package via Composer:
composer require kfoobar/laravel-euro-vat
Publish the configuration file:
php artisan vendor:publish --provider="KFoobar\EuroVAT\EuroVATServiceProvider"
Configuration
The configuration file config/euro-vat.php allows you to set:
urls.number: Endpoint used when validating a VAT number online.urls.status: Endpoint used for the VIES status check.ttl.number: Cache lifetime in minutes for VAT validation results.ttl.status: Cache lifetime in minutes for VIES status results.
Usage
The main service exposes:
validate(string $number, ?string $country = null): ?stringvalidateOffline(string $number, ?string $country = null): ?stringvalidateOnline(string $number, string $country): ?stringstatus(?string $country = null): bool
Using the Facade
Validate a VAT number:
use KFoobar\EuroVAT\Facades\EuroVAT; EuroVAT::validate('SE123456789012'); EuroVAT::validateOffline('SE123456789012'); EuroVAT::validateOnline('123456789012', 'SE'); EuroVAT::validate('123456789012', 'SE'); EuroVAT::status('SE');
validate() is the default entrypoint and performs online validation.
validateOffline() only performs the local VAT format check. No external HTTP request is made.
validateOnline() sends the provided VAT number and country code directly to the EU VIES API and caches the response. It does not normalize or pre-validate the VAT number locally.
Using the Validation Rule
use KFoobar\EuroVAT\Rules\VatId; $request->validate([ 'vat_number' => ['required', new VatId('SE')], ]);
Using the vat_id Validator Extension
$request->validate([ 'vat_number' => 'required|vat_id:SE', ]);
Contributing
Contributions are welcome!
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-26