Skip to content

Commit

Permalink
Merge branch '6.x' into 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Mar 30, 2021
2 parents 7c4b97f + 006ba38 commit 8d22e03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public function detach($ids = null, $touch = true)
return 0;
}

$query->whereIn($this->relatedPivotKey, (array) $ids);
$query->whereIn($this->getQualifiedRelatedPivotKeyName(), (array) $ids);
}

// Once we have all of the conditions set on the statement, we are ready
Expand Down Expand Up @@ -567,7 +567,7 @@ public function newPivotQuery()
$query->whereNull(...$arguments);
}

return $query->where($this->foreignPivotKey, $this->parent->{$this->parentKey});
return $query->where($this->getQualifiedForeignPivotKeyName(), $this->parent->{$this->parentKey});
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/Database/DatabaseEloquentMorphToManyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public function testDetachRemovesPivotTableRecord()
$relation = $this->getMockBuilder(MorphToMany::class)->onlyMethods(['touchIfTouching'])->setConstructorArgs($this->getRelationArguments())->getMock();
$query = m::mock(stdClass::class);
$query->shouldReceive('from')->once()->with('taggables')->andReturn($query);
$query->shouldReceive('where')->once()->with('taggable_id', 1)->andReturn($query);
$query->shouldReceive('where')->once()->with('taggables.taggable_id', 1)->andReturn($query);
$query->shouldReceive('where')->once()->with('taggable_type', get_class($relation->getParent()))->andReturn($query);
$query->shouldReceive('whereIn')->once()->with('tag_id', [1, 2, 3]);
$query->shouldReceive('whereIn')->once()->with('taggables.tag_id', [1, 2, 3]);
$query->shouldReceive('delete')->once()->andReturn(true);
$relation->getQuery()->shouldReceive('getQuery')->andReturn($mockQueryBuilder = m::mock(stdClass::class));
$mockQueryBuilder->shouldReceive('newQuery')->once()->andReturn($query);
Expand All @@ -64,7 +64,7 @@ public function testDetachMethodClearsAllPivotRecordsWhenNoIDsAreGiven()
$relation = $this->getMockBuilder(MorphToMany::class)->onlyMethods(['touchIfTouching'])->setConstructorArgs($this->getRelationArguments())->getMock();
$query = m::mock(stdClass::class);
$query->shouldReceive('from')->once()->with('taggables')->andReturn($query);
$query->shouldReceive('where')->once()->with('taggable_id', 1)->andReturn($query);
$query->shouldReceive('where')->once()->with('taggables.taggable_id', 1)->andReturn($query);
$query->shouldReceive('where')->once()->with('taggable_type', get_class($relation->getParent()))->andReturn($query);
$query->shouldReceive('whereIn')->never();
$query->shouldReceive('delete')->once()->andReturn(true);
Expand Down

0 comments on commit 8d22e03

Please sign in to comment.