You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -14,30 +14,90 @@ The idea around this library is to make it very easy for a developer to define i
14
14
15
15
After each first time successful sync, the CRM Object primary key will be stored in a mapping table against the local table primary key. This allows for quicker loading times for future changes.
16
16
17
-
Update your Model with 4 properties that define the rules for 3rd-party CRM synchronization:
> `config('sync_modeltocrm.api.providers.{provider}.object_table_mapping')` will be used if this is not provided.
25
+
-@var array `$syncModelCrmDeleteRules`; _\*Required for delete actions_
26
+
-@var array `$syncModelCrmActiveRules`; _\*Required for restore actions_
27
+
-@var array `$syncModelCrmAssociateRules`; _\*Required when associations are true_
25
28
26
29
Looking at the below example:
27
-
1. the `User` Model will syncronize to both the `Sandbox` and `Production`**HubSpot** environments _($syncModelCrmEnvironment)_.
30
+
31
+
1. The `User` Model will syncronize to both the `Sandbox` and `Production`**HubSpot** environments _($syncModelCrmEnvironment)_.
28
32
2. It will only syncronize the `name` and `email` properties to the HubSpot corresponding `firstname` and `email` fields _($syncModelCrmPropertyMapping)_.
29
-
3. When there is no internal mapping yet stored, the CRM record will be uniquely loaded using the `email` property _($syncModelCrmUniqueSearch)_.
33
+
3. When there are no internal mapping yet stored, the CRM record will be uniquely loaded using the `email` property _($syncModelCrmUniqueSearch)_.
30
34
4. In order for the script to know which remote CRM object relates to the User model, `contact`_($syncModelCrmRelatedObject)_ have to be defined as the remote item.
31
35
5. The _($syncModelCrmDeleteRules)_ property is used to instruct the Crm what action to take when a local record is deleted/removed. For example, when _SoftDeletes_ are enabled locally, the crm will use the `soft_delete` rules to update the crm records or alternatively Archive the record in the crm.
32
36
6. The reverse to the above, _($syncModelCrmActiveRules)_ will be used to define the action that will be taken when deleted records are activated again.
33
37
7. Finally, the non-required _($syncModelCrmAssociateRules)_ property is used to define the relationship (associations) between objects. e.g. `user` to `entity`.
34
38
35
39
```PHP
40
+
<?php
41
+
42
+
namespace App\Models;
43
+
44
+
// use Illuminate\Contracts\Auth\MustVerifyEmail;
45
+
use Illuminate\Database\Eloquent\Factories\HasFactory;
46
+
use Illuminate\Foundation\Auth\User as Authenticatable;
47
+
use Illuminate\Notifications\Notifiable;
48
+
use Laravel\Sanctum\HasApiTokens;
49
+
use App\Models\Entity;
50
+
use Illuminate\Database\Eloquent\SoftDeletes;
51
+
use Wazza\SyncModelToCrm\Http\Controllers\CrmProviders\HubSpotController;
52
+
use Wazza\SyncModelToCrm\Traits\crmTrait;
53
+
36
54
class User extends Authenticatable
37
55
{
38
-
// .
39
-
// ..
40
-
// ... original Model content above.
56
+
use HasApiTokens, HasFactory, Notifiable, SoftDeletes;
57
+
58
+
// include this if you wish to use the `Mutators function` or
59
+
// $this->syncToCrm() directly as appose to the observer method
60
+
use crmTrait;
61
+
62
+
/**
63
+
* The attributes that are mass assignable.
64
+
*
65
+
* @var array<int,string>
66
+
*/
67
+
protected $fillable = [
68
+
'name',
69
+
'email',
70
+
'password',
71
+
];
72
+
73
+
/**
74
+
* The attributes that should be hidden for serialization.
75
+
*
76
+
* @var array<int,string>
77
+
*/
78
+
protected $hidden = [
79
+
'password',
80
+
'remember_token',
81
+
];
82
+
83
+
/**
84
+
* The attributes that should be cast.
85
+
*
86
+
* @var array<string,string>
87
+
*/
88
+
protected $casts = [
89
+
'email_verified_at' => 'datetime',
90
+
'password' => 'hashed',
91
+
];
92
+
93
+
/**
94
+
* Function that will be used to return the relationship data
3. Inside an event job. This is a good method to separate the logic from the save event and put the sync in a job queue to be processed shortly after the record has been saved.
353
+
354
+
4. Inside an event job. This is a good method to separate the logic from the save event and put the sync in a job queue to be processed shortly after the record has been saved.
4. Below are some of the environment keys that can be added to your _.env_ configuration. If you need more information what each item does, refer to the `config/sync_modeltocrm.php` config file.
0 commit comments