File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -78,3 +78,22 @@ class MyModel extends Model
78
78
}
79
79
```
80
80
This trait will automatically sync related model every time a m-n relation is changed or the model is saved.
81
+
82
+ ### Advanced sync options
83
+ Sometimes the content of a model must be synchronized with an unrelated or you need to trigger the sync just in some conditions.
84
+
85
+ You can customize what an when to trigger related mode synchromization by changing the return value of ` getRelationsToSyncWithFirebase ` :
86
+ accepted value for the array values are:
87
+ - simple: 'relation_name' - simple relation synching
88
+ - with filter: 'relation_name' => function($query){} - filter the relationship
89
+ - Custom query: function(){} - return a query to sync with Firebase
90
+
91
+ ``` php
92
+ function getRelationsToSyncWithFirebase(){
93
+ return [
94
+ 'target',//Normal
95
+ 'client'=>function($query){$query->where('is_premium','=',1);},//With filter
96
+ function(){ return UnrelatedModel::where('condition','value');},//Custom query
97
+ ];
98
+ }
99
+ ```
You can’t perform that action at this time.
0 commit comments