18
18
use MongoDB \Model \BSONDocument ;
19
19
20
20
use function array_key_exists ;
21
- use function array_merge ;
21
+ use function array_replace ;
22
22
use function collect ;
23
23
use function is_array ;
24
24
use function is_object ;
@@ -270,7 +270,7 @@ public function firstOrCreate(array $attributes = [], array $values = [])
270
270
271
271
// createOrFirst is not supported in transaction.
272
272
if ($ this ->getConnection ()->getSession ()?->isInTransaction()) {
273
- return $ this ->create (array_merge ($ attributes , $ values ));
273
+ return $ this ->create (array_replace ($ attributes , $ values ));
274
274
}
275
275
276
276
return $ this ->createOrFirst ($ attributes , $ values );
@@ -284,7 +284,7 @@ public function createOrFirst(array $attributes = [], array $values = [])
284
284
}
285
285
286
286
try {
287
- return $ this ->create (array_merge ($ attributes , $ values ));
287
+ return $ this ->create (array_replace ($ attributes , $ values ));
288
288
} catch (BulkWriteException $ e ) {
289
289
if ($ e ->getCode () === self ::DUPLICATE_KEY_ERROR ) {
290
290
return $ this ->where ($ attributes )->first () ?? throw $ e ;
@@ -309,7 +309,7 @@ protected function addUpdatedAtColumn(array $values)
309
309
}
310
310
311
311
$ column = $ this ->model ->getUpdatedAtColumn ();
312
- $ values = array_merge (
312
+ $ values = array_replace (
313
313
[$ column => $ this ->model ->freshTimestampString ()],
314
314
$ values ,
315
315
);
0 commit comments