PHP code example of danielebarbaro / laravel-vat-eu-validator

1. Go to this page and download the library: Download danielebarbaro/laravel-vat-eu-validator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

danielebarbaro / laravel-vat-eu-validator example snippets


use Danielebarbaro\LaravelVatEuValidator\Facades\VatValidatorFacade as VatValidator;

// Check VAT format and VIES existence
VatValidator::validate('IT12345');

// Check VAT format
VatValidator::validateFormat('IT12345678901'); 

// Check VAT existence
VatValidator::validateExistence('IT12345678901');


use Illuminate\Http\Request;

class Controller {

    public function foo(Request $request) 
    {
        $request->validate([
            'bar_field' => ['vat_number'],
        ]);
        
        $request->validate([
            'bar_field' => ['vat_number_exist'],
        ]);
        
        $request->validate([
            'bar_field' => ['vat_number_format'],
       ]);
    }
}

use Illuminate\Http\Request;
use Danielebarbaro\LaravelVatEuValidator\Rules;

class Controller {

    public function foo(Request $request) 
    {
        $request->validate([
            'bar_field' => [ new Rules\VatNumber() ],
            'bar_field' => [ new Rules\VatNumberExist() ],
            'bar_field' => [ new Rules\VatNumberFormat() ],
        ]);
    }
}