PHP code example of nyoncode / laravel-ares

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

    

nyoncode / laravel-ares example snippets


use NyonCode\Ares\Contracts\AresClientInterface;

final class CompanyLookupService
{
    public function __construct(
        private readonly AresClientInterface $ares,
    ) {}

    public function companyName(string $ic): ?string
    {
        return $this->ares->findCompany($ic)?->name;
    }
}

use NyonCode\Ares\Facades\Ares;

$normalizedIc = Ares::normalizeIc('27 074 358');
$company = Ares::findCompanyOrFail($normalizedIc);

dump($company->name);
dump($company->registeredOffice?->formatted);
dump($company->registration->naceCodes);

final class CompanyData
{
    public readonly string $ic;
    public readonly string $name;
    public readonly ?string $dic;
    public readonly ?string $dicSkDph;
    public readonly ?AddressData $registeredOffice;
    public readonly ?DeliveryAddressData $deliveryAddress;
    public readonly RegistrationData $registration;
    public readonly array $rawData;
}

// Search by company name
$results = Ares::search('Asseco');

// Search by IC prefix
$results = Ares::search('2707', 5);

// Using the global helper
$results = ares_search('Skoda');

$schedule->command('ares:index --refresh-stale')->daily();
bash
php artisan vendor:publish --tag=laravel-ares::config
bash
php artisan migrate
bash
# Index specific subjects
php artisan ares:index 27074358 25596641

# Refresh stale records (older than configured stale_days)
php artisan ares:index --refresh-stale

# Custom stale threshold and limit
php artisan ares:index --refresh-stale --stale-days=14 --limit=200
bash
# Test ARES API connectivity
php artisan ares:test 27074358

# Index subjects
php artisan ares:index 27074358

# Show indexing statistics
php artisan ares:index

# Refresh stale records
php artisan ares:index --refresh-stale
bash
composer analyse