Skip to content

Commit

Permalink
Fixes belongsToMany detach() failing when scope is defined on the rel…
Browse files Browse the repository at this point in the history
…ationship (#3)

Refs: octobercms/october#5499
  • Loading branch information
LukeTowers authored Mar 6, 2021
1 parent 02c0c9b commit e1686e0
Show file tree
Hide file tree
Showing 2 changed files with 231 additions and 118 deletions.
5 changes: 3 additions & 2 deletions src/Database/Relations/DefinedConstraints.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public function addDefinedConstraintsToQuery($query, $args = null)
* Scope
*/
if ($scope = array_get($args, 'scope')) {
$query->$scope($this->parent);
$scopeMethod = 'scope' . ucfirst($scope);
$this->getRelated()->{$scopeMethod}($query, $this->parent);
}
}

Expand All @@ -141,6 +142,6 @@ public function newPivotQuery()

return $query
->join($related->getTable(), $related->getQualifiedKeyName(), '=', $this->getOtherKey())
->select($this->getTable().'.*');
->select($this->getTable() . '.*');
}
}
Loading

0 comments on commit e1686e0

Please sign in to comment.