PHP code example of doniyor / bitrix24-laravel

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

    

doniyor / bitrix24-laravel example snippets


use Doniyor\Bitrix24\Bitrix24Manager;
use Doniyor\Bitrix24\DTO\CRM\LeadFieldsDto;

public function __construct(private Bitrix24Manager $bitrix) {}

public function createLead(): int
{
    return $this->bitrix->crm()->leads()->add(
        new LeadFieldsDto(
            title: 'New lead',
            name: 'Jane',
            lastName: 'Doe',
            phones: [
                ['VALUE' => '+123456789', 'VALUE_TYPE' => 'WORK'],
            ],
            emails: [
                ['VALUE' => '[email protected]', 'VALUE_TYPE' => 'WORK'],
            ],
        )
    );
}

use Doniyor\Bitrix24\Facades\Bitrix24;
use Doniyor\Bitrix24\DTO\CRM\LeadFieldsDto;

$lead = Bitrix24::crm()->leads()->get(42);

Bitrix24::crm()->leads()->update(
    42,
    (new LeadFieldsDto(title: 'Existing lead'))
        ->withExtra(['STATUS_ID' => 'CONVERTED'])
);

use Doniyor\Bitrix24\Facades\Bitrix24;
use Doniyor\Bitrix24\CRM\Mappers\LeadResponseMapper;

$payload = Bitrix24::crm()->leads()->get(42);
$lead = app(LeadResponseMapper::class)->map($payload);

echo $lead->title;
bash
php artisan vendor:publish --tag=bitrix24-config