PHP code example of beziworld / laravel-company-data

1. Go to this page and download the library: Download beziworld/laravel-company-data 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/ */

    

beziworld / laravel-company-data example snippets


use Beziworld\CompanyData\Facades\Gus;

$company = Gus::findByNip('526-104-08-28');   // or findByRegon(), findByKrs(), findManyByNip([...])

$company->name;            // "GŁÓWNY URZĄD STATYSTYCZNY"
$company->regon;           // "000331501"
$company->type;            // EntityType::LegalEntity
$company->address();       // "ul. Test-Krucza 208, 00-925 Warszawa"
$company->isActive();

Gus::fullReport($company);  // all registered fields; the report is chosen from the entity type
Gus::pkd($company);         // PKD codes
Gus::dataDate();            // date of the register data

use Beziworld\CompanyData\Facades\WhiteList;

$taxpayer = WhiteList::searchNip('5261040828');           // state of the register today
$taxpayer = WhiteList::searchNip('5261040828', '2026-10-01');

$taxpayer?->status;              // VatStatus::Active / Exempt / NotRegistered
$taxpayer?->accountNumbers;      // list of 26-digit NRB numbers
$taxpayer?->representatives;

$check = WhiteList::checkAccount('5261040828', 'PL61 1090 1014 0000 0712 1981 2874');
$check->assigned;                // true when the account belongs to an active VAT payer (virtual accounts 

use Beziworld\CompanyData\Facades\Vies;

$result = Vies::check('DE811569869');   // or check('811569869', 'DE')
$result->valid;
$result->name;                          // null when the member state does not disclose it
$result->requestIdentifier;             // consultation number when requester data are configured

Vies::isValid('PL5261040828');
Vies::status();                         // ['PL' => true, 'DE' => false, ...]

Route::get('/api/company/{nip}', function (string $nip) {
    $company = Gus::findByNip($nip);

    abort_if($company === null, 404);

    return [
        'name' => $company->name,
        'street' => $company->streetLine(),
        'postal_code' => $company->postalCode,
        'city' => $company->postCity ?? $company->city,
        'regon' => $company->regon,
    ];
});

public function pay(Invoice $invoice): void
{
    $check = WhiteList::checkAccount($invoice->supplier_nip, $invoice->bank_account);

    if (! $check->assigned && $invoice->gross >= 15000) {
        throw new SupplierAccountNotVerified($invoice);
    }

    $invoice->payments()->create([
        'amount' => $invoice->gross,
        'white_list_request_id' => $check->requestId,
    ]);
}

try {
    $reverseCharge = Vies::check($order->vat_number)->valid;
} catch (ViesException $e) {
    $reverseCharge = false;   // or queue a re-check when $e->isTemporary()
}