Skip to content

Commit

Permalink
Merge pull request #21 from GrahamCampbell/patch-1
Browse files Browse the repository at this point in the history
Use parent performJoin
  • Loading branch information
ddzobov authored Jul 15, 2024
2 parents 34c9704 + bd3050a commit e420159
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/Relations/BelongsToManySoft.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,12 @@ protected function performJoin($query = null)
{
$query = $query ?: $this->query;

// We need to join to the intermediate table on the related model's primary
// key column with the intermediate table's foreign key for the related
// model instance. Then we can set the "where" for the parent models.
$baseTable = $this->related->getTable();

$key = $baseTable.'.'.$this->relatedKey;

$query->join($this->table, $key, '=', $this->getQualifiedRelatedPivotKeyName());
parent::performJoin($query);

$query->when($this->withSoftDeletes, function (Builder $query) {
$query->whereNull($this->getQualifiedDeletedAtColumnName());
});

return $this;
}
}
}

0 comments on commit e420159

Please sign in to comment.