Skip to content

Commit 070a611

Browse files
Prevent ket casting for build eagerLoading Dictionary
1 parent ed36b81 commit 070a611

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Relations/BelongsToMany.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,12 @@ protected function buildDictionary(Collection $results)
386386

387387
foreach ($results as $result) {
388388
foreach ($result->$foreign as $item) {
389+
390+
//Prevent if id is non keyable
391+
if ($item instanceof \MongoDB\BSON\ObjectId) {
392+
$item = (string) $item;
393+
}
394+
389395
$dictionary[$item][] = $result;
390396
}
391397
}

0 commit comments

Comments
 (0)