PHP code example of synergitech / laravel-salesforce

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

    

synergitech / laravel-salesforce example snippets


use SynergiTech\Salesforce\Facades\Salesforce;

// Get an individual record by Id
Salesforce::table('MyTable')->find('YourIdHere');

Salesforce::table('MyTable')->find('YourIdHere');

Salesforce::table('MyTable')->findMany(['YourId1Here', 'YourId2Here']);

$response = Salesforce::table('MyTable')->create([
    'Name' => 'John Doe',
]);

[
    'id' => '', // Salesforce Id
    'success' => true,
    'errors' => [],
    'data' => [
        // Full record data
    ],
]

$response = Salesforce::table('MyTable')->update('Id', [
    'Name' => 'John Doe',
]);

$response = Salesforce::table('MyTable')->createOrUpdate('My_External_Id__c', 'ExternalId', [
    'Name' => 'John Doe',
]);

[
    'id' => '', // Salesforce Id
    'success' => true,
    'errors' => [],
    'created' => true, // True/False depending on whether the record was created or updated
    'data' => [
        // Full record data
    ],
]

Salesforce::table('MyTable')->delete('Id');

// Basic where clause
Salesforce::table('MyTable')->where('Name', 'John Doe')->get();

// You can also use any of the following operators

// Equals and Not Equals
Salesforce::table('MyTable')->where('Name', '=', 'John Doe')->get();
Salesforce::table('MyTable')->where('Name', '!=', 'John Doe')->get();

// Comparisons
Salesforce::table('MyTable')->where('Age', '<', 30)->get();
Salesforce::table('MyTable')->where('Age', '<=', 30)->get();
Salesforce::table('MyTable')->where('Age', '>', 30)->get();
Salesforce::table('MyTable')->where('Age', '>=', 30)->get();

// Like
Salesforce::table('MyTable')->where('Name', 'LIKE', 'John %')->get();
Salesforce::table('MyTable')->where('Name', 'LIKE', '% Middlename %')->get();
Salesforce::table('MyTable')->where('Name', 'LIKE', '% Doe')->get();

Salesforce::table('MyTable')->whereIn('Country', ['United Kingdom', 'United States'])->get();

// Ascending (default)
Salesforce::table('MyTable')->orderBy('Age')->get();

// Descending
Salesforce::table('MyTable')->orderBy('Age', 'DESC')->get();

Salesforce::table('MyTable')->orderBy('LastLoginDate')->nullsLast()->get();

Salesforce::table('MyTable')->where('Name', 'LIKE', 'John%')->limit(20)->get();