PHP code example of mncee / salesforce-sync

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

    

mncee / salesforce-sync example snippets


// bootstrap/providers.php

return [
    App\Providers\AppServiceProvider::class,
    CEE\Salesforce\Laravel\SalesforceServiceProvider::class,
];

// config/app.php

return [
    
    //...
    
    'aliases' => Facade::defaultAliases()->merge([
        'Salesforce' => \CEE\Salesforce\Laravel\Facades\Salesforce::class,
    ])->toArray(),
]

// config/app.php

return [
    
    //...
    
    'providers' => [
        // ...
        CEE\Salesforce\Laravel\SalesforceServiceProvider::class,
    ],
    
    'aliases' => [
        // ...
        'Salesforce' => \CEE\Salesforce\Laravel\Facades\Salesforce::class,
    ],
    
];

class Contact extends SyncObject
{
    public $objectName = 'Contact'; // Saleforce Object Name
    ...
}

$salesforceContact = new Contact();
$salesforceContact->push();
$salesforceContact->pull();

public function push_<Salesforce field name>()
public function pull_<Salesforce field name>($value)

    public function push_FirstName() {
        return DB::table('contact')->where('id', 1)->value('first_name');
    }

    public function pull_FirstName($firstName) {
        DB::table('contact')->where('id', 1)->update(['first_name' => $firstName]);
    }

SyncObject::objectName('Contact')
	->id('00A10000001aBCde')
	->pushFields(['FirstName' => 'John', 'LastName' => 'Doe'])
	->push();
	
$salesforceContact = SyncObject::objectName('Contact')
	->id('00A10000001aBCde')
	->pullFields(['FirstName', 'LastName'])
	->pull();