We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e30d937 commit 46818eeCopy full SHA for 46818ee
src/Traits/SyncRelatedWithFirebase.php
@@ -43,20 +43,29 @@ final public function syncRelatedWithFirebase($only=null){
43
}
44
45
foreach($related AS $k=>$v){
46
+ $el = null;
47
+ /**@var Model $el**/
48
+
49
+ // Get the related model to sync
50
if(is_numeric($k)){
51
if(is_string($v)){
52
//Simple relationship array
- $this->$v->syncWithFirebase();
53
+ $el = $this->$v;
54
}elseif(is_callable($v)){
55
//Custom query
- $v()->get()->syncWithFirebase();
56
+ $el = $v()->get();
57
58
}else{
59
if(is_callable($v)){
60
//Query filter
- $v($this->$k())->get()->syncWithFirebase();
61
+ $el = $v($this->$k())->get();
62
63
64
65
+ // Sync the model IF not null
66
+ if($el){
67
+ $el->syncWithFirebase();
68
+ }
69
70
71
0 commit comments