File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -328,12 +328,20 @@ public function attributesToArray()
328
328
// MongoDB related objects to a string representation. This kind
329
329
// of mimics the SQL behaviour so that dates are formatted
330
330
// nicely when your models are converted to JSON.
331
- foreach ( $ attributes as $ key => & $ value ) {
331
+ $ convertMongoObjects = function (& $ value ) use (& $ convertMongoObjects ) {
332
332
if ($ value instanceof ObjectID) {
333
333
$ value = (string ) $ value ;
334
334
} elseif ($ value instanceof Binary) {
335
335
$ value = (string ) $ value ->getData ();
336
+ } elseif (is_array ($ value )) {
337
+ foreach ($ value as &$ embedValue ) {
338
+ $ convertMongoObjects ($ embedValue );
339
+ }
336
340
}
341
+ };
342
+
343
+ foreach ($ attributes as $ key => &$ value ) {
344
+ $ convertMongoObjects ($ value );
337
345
}
338
346
339
347
return $ attributes ;
You can’t perform that action at this time.
0 commit comments