PHP code example of clystnet / vtiger

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

    

clystnet / vtiger example snippets


use Vtiger;

$data = array(
    'assigned_user_id' => '',
);

Vtiger::create($MODULE_NAME, json_encode($data));

$id = '4x12';

$obj = Vtiger::retrieve($id);

// do someting with the result
var_dump($obj);

$id = '4x12';

$obj = Vtiger::retrieve($id);

$obj->result->field_name = 'Your new value';

$update = Vtiger::update($obj->result);

$id = '4x12';

$obj = Vtiger::retrieve($id);

// do someting with the result
var_dump($obj);

    $dataType = 'phone';
    $phoneNumber = '1234567890';
    $module = 'Leads';
    $columns = ['phone', 'fax']; //Must be an array
    
    Vtiger::lookup($dataType, $phoneNumber, $module, $columns);

$query = DB::table('Leads')->select('id', 'firstname', 'lastname')->where('firstname', 'John');

$obj = Vtiger::search('Leads', $query);

//loop over result
foreach($obj->result as $result) {
    // do something
}

$obj = Vtiger::search('Leads', $query, false);

$query = "SELECT * FROM ModuleName;";

$obj = Vtiger::query($query);

//loop over result
foreach($obj->result as $result) {
    // do something
}

$moduleDescription = (Vtiger:describe("Contacts"))->result;

    php artisan vendor:publish --tag="vtiger"