Skip to content

Commit 1750bac

Browse files
committed
Pass options from Eloquent builder to Query builder, fixes mongodb#558
1 parent 73d2679 commit 1750bac

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Jenssegers/Mongodb/Eloquent/Builder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ class Builder extends EloquentBuilder
2121
* Update a record in the database.
2222
*
2323
* @param array $values
24+
* @param array $options
2425
* @return int
2526
*/
26-
public function update(array $values)
27+
public function update(array $values, array $options = [])
2728
{
2829
// Intercept operations on embedded models and delegate logic
2930
// to the parent relation instance.
@@ -33,7 +34,7 @@ public function update(array $values)
3334
return 1;
3435
}
3536

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

3940
/**

tests/QueryBuilderTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,14 @@ public function testUpsert()
429429
);
430430

431431
$this->assertEquals(1, DB::collection('items')->count());
432+
433+
Item::where('name', 'spoon')
434+
->update(
435+
['amount' => 1],
436+
['upsert' => true]
437+
);
438+
439+
$this->assertEquals(2, DB::collection('items')->count());
432440
}
433441

434442
public function testUnset()

0 commit comments

Comments
 (0)