Skip to content

Commit

Permalink
Merge pull request #29645 from staudenmeir/eloquent-insert
Browse files Browse the repository at this point in the history
[5.8] Fix insertOrIgnore() and insertUsing() as Eloquent queries
  • Loading branch information
taylorotwell authored Aug 20, 2019
2 parents 46d7e96 + d86144f commit b449e0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Builder
* @var array
*/
protected $passthru = [
'insert', 'insertGetId', 'getBindings', 'toSql', 'dump', 'dd',
'insert', 'insertOrIgnore', 'insertGetId', 'insertUsing', 'getBindings', 'toSql', 'dump', 'dd',
'exists', 'doesntExist', 'count', 'min', 'max', 'avg', 'average', 'sum', 'getConnection',
];

Expand Down
15 changes: 15 additions & 0 deletions tests/Database/DatabaseEloquentBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,21 @@ public function testQueryPassThru()
$builder->getQuery()->shouldReceive('insert')->once()->with(['bar'])->andReturn('foo');

$this->assertEquals('foo', $builder->insert(['bar']));

$builder = $this->getBuilder();
$builder->getQuery()->shouldReceive('insertOrIgnore')->once()->with(['bar'])->andReturn('foo');

$this->assertEquals('foo', $builder->insertOrIgnore(['bar']));

$builder = $this->getBuilder();
$builder->getQuery()->shouldReceive('insertGetId')->once()->with(['bar'])->andReturn('foo');

$this->assertEquals('foo', $builder->insertGetId(['bar']));

$builder = $this->getBuilder();
$builder->getQuery()->shouldReceive('insertUsing')->once()->with(['bar'], 'baz')->andReturn('foo');

$this->assertEquals('foo', $builder->insertUsing(['bar'], 'baz'));
}

public function testQueryScopes()
Expand Down

0 comments on commit b449e0e

Please sign in to comment.