laravel-salesforce maintained by digitaltouch
Description
A Laravel library for Salesforce built on top of omniphx/forrest
Author
Last update
2021/09/10 13:02
(dev-master)
License
Downloads
17
Tags
Laravel Salesforce
A Laravel library for Salesforce built on top of omniphx/forrest.
Navigation
Installation
Install the package:
composer require digitaltouch/laravel-salesforce
Publish the configuration file (it will publish a config/forrest.php file):
php artisan vendor:publish
Extend the model:
<?php
namespace App\Models;
use Digitaltouch\Salesforce\Models\Model as BaseModel;
abstract class Model extends BaseModel
{
//
}
Usage
Facade
To access the facade (it will be automatically registered) methods, simply define use statement:
use Salesforce;
Model
To define the Salesforce object associated with the model:
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'ObjectName__c';
To define the list of object fields:
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'ObjectFieldA' => 'fieldAliasA',
'ObjectFieldB__c' => 'fieldAliasB',
];
To define the list of readonly fields (fields that are used for select and hidden for save):
/**
* The attributes that should be hidden for save.
*
* @var array
*/
protected $readonly = [
'fieldAliasA',
];
To define the list of virtual fields (fields that are hidden for select and for save):
/**
* The attributes that should be hidden for select and save.
*
* @var array
*/
protected $virtual = [
'fieldAliasB',
];
Methods
-
Facade
Salesforce::fetch($query)- fetch a single recordSalesforce::fetchAll($query)- fetch all recordsSalesforce::insert($object, $record)- insert a single recordSalesforce::update($object, $field, $record)- update a single recordSalesforce::upsert($object, $field, $record)- update or insert a single recordSalesforce::delete($object, $field, $id)- delete a single recordSalesforce::massInsert($object, $records)- mass insert recordsSalesforce::massUpdate($object, $field, $records)- mass update recordsSalesforce::massUpsert($object, $field, $records)- mass update or insert recordsSalesforce::massDelete($object, $field, $ids)- mass delete records
-
Model
Model::all()- get all modelsModel::findAll($where?, $orderBy?)- find models by optional where clauseModel::find($id)- find a model by the identifierModel::findOrFail($id)- find a model by the identifier, if no result is found, an exception will be thrown$model->getId()- get the model identifier
Casting
All native Laravel casts should work as expected. Additional casts:
multi_picklist- casts values of multi-select picklist from/to array