Skip to content

Commit 8d22e03

Browse files
Merge branch '6.x' into 8.x
2 parents 7c4b97f + 006ba38 commit 8d22e03

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ public function detach($ids = null, $touch = true)
446446
return 0;
447447
}
448448

449-
$query->whereIn($this->relatedPivotKey, (array) $ids);
449+
$query->whereIn($this->getQualifiedRelatedPivotKeyName(), (array) $ids);
450450
}
451451

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

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

573573
/**

tests/Database/DatabaseEloquentMorphToManyTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public function testDetachRemovesPivotTableRecord()
4848
$relation = $this->getMockBuilder(MorphToMany::class)->onlyMethods(['touchIfTouching'])->setConstructorArgs($this->getRelationArguments())->getMock();
4949
$query = m::mock(stdClass::class);
5050
$query->shouldReceive('from')->once()->with('taggables')->andReturn($query);
51-
$query->shouldReceive('where')->once()->with('taggable_id', 1)->andReturn($query);
51+
$query->shouldReceive('where')->once()->with('taggables.taggable_id', 1)->andReturn($query);
5252
$query->shouldReceive('where')->once()->with('taggable_type', get_class($relation->getParent()))->andReturn($query);
53-
$query->shouldReceive('whereIn')->once()->with('tag_id', [1, 2, 3]);
53+
$query->shouldReceive('whereIn')->once()->with('taggables.tag_id', [1, 2, 3]);
5454
$query->shouldReceive('delete')->once()->andReturn(true);
5555
$relation->getQuery()->shouldReceive('getQuery')->andReturn($mockQueryBuilder = m::mock(stdClass::class));
5656
$mockQueryBuilder->shouldReceive('newQuery')->once()->andReturn($query);
@@ -64,7 +64,7 @@ public function testDetachMethodClearsAllPivotRecordsWhenNoIDsAreGiven()
6464
$relation = $this->getMockBuilder(MorphToMany::class)->onlyMethods(['touchIfTouching'])->setConstructorArgs($this->getRelationArguments())->getMock();
6565
$query = m::mock(stdClass::class);
6666
$query->shouldReceive('from')->once()->with('taggables')->andReturn($query);
67-
$query->shouldReceive('where')->once()->with('taggable_id', 1)->andReturn($query);
67+
$query->shouldReceive('where')->once()->with('taggables.taggable_id', 1)->andReturn($query);
6868
$query->shouldReceive('where')->once()->with('taggable_type', get_class($relation->getParent()))->andReturn($query);
6969
$query->shouldReceive('whereIn')->never();
7070
$query->shouldReceive('delete')->once()->andReturn(true);

0 commit comments

Comments
 (0)