Skip to content

Commit c495af5

Browse files
committed
Pass options from Eloquent builder to Query builder, fixes #558
1 parent 285ebda commit c495af5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Jenssegers/Mongodb/Eloquent/Builder.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ class Builder extends EloquentBuilder
2020
* Update a record in the database.
2121
*
2222
* @param array $values
23+
* @param array $options
2324
* @return int
2425
*/
25-
public function update(array $values)
26+
public function update(array $values, array $options = [])
2627
{
2728
// Intercept operations on embedded models and delegate logic
2829
// to the parent relation instance.
@@ -32,7 +33,7 @@ public function update(array $values)
3233
return 1;
3334
}
3435

35-
return parent::update($values);
36+
return $this->query->update($this->addUpdatedAtColumn($values), $options);
3637
}
3738

3839
/**

tests/QueryBuilderTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,14 @@ public function testUpsert()
426426
);
427427

428428
$this->assertEquals(1, DB::collection('items')->count());
429+
430+
Item::where('name', 'spoon')
431+
->update(
432+
['amount' => 1],
433+
['upsert' => true]
434+
);
435+
436+
$this->assertEquals(2, DB::collection('items')->count());
429437
}
430438

431439
public function testUnset()

0 commit comments

Comments
 (0)