File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -146,17 +146,19 @@ public static function bootHasSnapshot()
146146 $ snapshot = $ model ->getSnapshot ();
147147 $ source = $ model ->source ()->with ($ model ->getSnapshotSourceRelationships ())->first ();
148148
149- $ fields = array_merge ($ source ->toArray (), $ snapshot ->getAttributes ());
149+ if ($ source && $ snapshot ){
150+ $ fields = array_merge ($ source ->toArray (), $ snapshot ->getAttributes ());
150151
151- foreach ($ fields as $ fieldName => $ value ) {
152- if (!$ model ->{$ fieldName }) {
153- $ model ->_snapshotSourceFields [$ fieldName ] = $ value ;
154- $ model ->setAttribute ($ fieldName , $ value );
152+ foreach ($ fields as $ fieldName => $ value ) {
153+ if (!$ model ->{$ fieldName }) {
154+ $ model ->_snapshotSourceFields [$ fieldName ] = $ value ;
155+ $ model ->setAttribute ($ fieldName , $ value );
156+ }
155157 }
156- }
157158
158- $ model [$ foreignKey ] = $ model ->snapshot ->source_id ;
159- $ model ->_snapshotSourceFields [$ foreignKey ] = $ model [$ foreignKey ];
159+ $ model [$ foreignKey ] = $ model ->snapshot ->source_id ;
160+ $ model ->_snapshotSourceFields [$ foreignKey ] = $ model [$ foreignKey ];
161+ }
160162 }
161163 });
162164 }
You can’t perform that action at this time.
0 commit comments