PHP code example of flinty916 / laravel-salesforce
1. Go to this page and download the library: Download flinty916/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/ */
flinty916 / laravel-salesforce example snippets
$contact = Contact::create([
'Name' => 'Test Contact'
]); // $contact will be type Contact, with the Id field populated only.
Contact::fields(['Id', 'Email', 'Name__c',]) // Use fields() to specify limited field sets for queries
->where('Email', 'LIKE', 'maurice%')
->orWhere('Id', '=', '003D000002TND2QIAX')
->all() // Fetches ALL records,
Contact::fields(['Id', 'Email', 'Name__c',]) // Use fields() to specify limited field sets for queries
->where('Email', 'LIKE', 'maurice%')
->orWhere('Id', '=', '003D000002TND2QIAX')
->limit(20) // Set a hard limit. orderBy methods available as well.
->get() // Fetches without handling pages.
->records() // Returns collection of Contact;
Contact::find('MyId'); // Returns an instance of Contact, runs FIELDS(ALL) behind the scenes.
$contact = Contact::find('MyId');
$contact->update([
'Name__c' => 'New Name'
]); // Returns no new data. Suggest a refetch/find operation afterwards to update state.