PHP code example of coolycow / laravel-dadata

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

    

coolycow / laravel-dadata example snippets


use Coolycow\Dadata\Facades\DadataSuggest;

// Всегда возвращает list<array> (пустой список, если совпадений нет)
$result = DadataSuggest::suggest('address', ['query' => 'Москва', 'count' => 2]);

$party = DadataSuggest::partyById('7707083893', ['branch_type' => 'MAIN']);

use Coolycow\Dadata\Facades\DadataClean;

$address = DadataClean::cleanAddress('мск сухонска 11/-89');
$phone = DadataClean::cleanPhone('тел 7165219 доб139');
$passport = DadataClean::cleanPassport('4509 235857');
$name = DadataClean::cleanName('Срегей владимерович иванов');
$email = DadataClean::cleanEmail('serega@yandex/ru');
$date = DadataClean::cleanDate('24/3/12');
$vehicle = DadataClean::cleanVehicle('форд фокус');

$balance = DadataClean::getBalance();
$stats = DadataClean::getStatistics();
$stats = DadataClean::getStatistics('2022-12-01');

$byIp = DadataClean::detectAddressByIp('8.8.8.8'); // Address|null

use Coolycow\Dadata\ClientClean;
use Coolycow\Dadata\ClientSuggest;

public function __construct(
    private ClientSuggest $suggest,
    private ClientClean $clean,
) {}
bash
php artisan vendor:publish --provider="Coolycow\Dadata\DadataServiceProvider"