1. Go to this page and download the library: Download optimacloud/zoho-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/ */
optimacloud / zoho-laravel example snippets
Zoho::useEnvironment(EUDataCenter::DEVELOPER());
use Optimacloud\Zoho\ZohoManager;
$response = ZohoManager::make(self::TESTING_MODULE);
$modules = $response->getAllModules();
use Optimacloud\Zoho\Zohoable;
use Optimacloud\Zoho\ZohoManager;
class Invoice extends Zohoable {
// this is your Zoho module API Name
protected $zoho_module_name = 'Payments';
public function searchCriteria(){
// you should return string of criteria that you want to find current record in crm with.
//EX:
return ZohoManager::make('Payments')
->where('PaymentID', $this->payment_id)
->andWhere('Order_ID', $this->order_id)
->getCriteria();
}
public function zohoMandatoryFields() {
// you should return array of mandatory fields to create module from this model
return ['Base_Currency' => $this->currency];
}
}
$invoice = \App\Invoice::find(1);
// to check if has zoho id stored on local database or not
$invoice->hasZohoId();
// to return the stored zoho id
$invoice->zohoId();
// that will search on zoho with provided criteria to find the record and associated your model with returned id if exist
// if you provided an `id` that will be used instead of searching on Zoho
$invoice->createOrUpdateZohoId($id = null);
// you can also send current model to zoho
// that wil use `zohoMandatoryFields` method to Serialize model to zohoObject
// Also you can pass additional fields as array to this method
$invoice->createAsZohoable($options = []);
use Optimacloud\Zoho\ZohoManager;
// we can now deal with leads module
$leads = ZohoManager::useModule('Leads');
// OR
$leads = ZohoManager::make('Leads');
// find record by its ID
$lead = $leads->getRecord('3582074000002383003');
$record = new Record();
$record->setId('3582074000002383003');
// Set value as field
$record->addFieldValue(Leads::FirstName(), 'Updated');
$record->addFieldValue(Leads::LastName(), 'Record');
// Set value as key value
$lead->setKeyValue('Phone', '5555555555552');
// Then call update() method
$response = $leads->update($record);
// create the record into zoho crm then get the created instance data
$response = $leads->create([
'First_Name' => 'Amr',
'Last_Name' => 'Emad',
'Email' => '[email protected]',
'Phone' => '012345678910',
]);
// delete record by its id
$lead = $leads->delete('3582074000002383003');
use Optimacloud\Zoho\ZohoManager;
$records = ZohoManager::useModule('Leads')->searchRecordsByWord('word to be searched');
$first_record = $records[0];
use Optimacloud\Zoho\ZohoManager;
$records = ZohoManager::useModule('Leads')->searchRecordsByPhone('12345678910');
$first_record = $records[0];
use Optimacloud\Zoho\ZohoManager;
$records = ZohoManager::make('Leads')->searchRecordsByEmail('[email protected]');
$first_record = $records[0];
use Optimacloud\Zoho\ZohoManager;
$records = ZohoManager::make('Leads')->searchRecordsByCriteria('(City:equals:NY) and (State:equals:Alden)')->get();
$first_record = $records[0];