Allows model scope with join (#4970)
More info in [this forum post](https://octobercms.com/forum/post/displays-a-related-model-with-scope-which-uses-join-doesnt-work-is-that-an-october-issue)
This commit is contained in:
parent
6e25c5a8d0
commit
2b22c0e49a
|
|
@ -127,14 +127,14 @@ class Relation extends FormWidgetBase
|
|||
$query->where($relationModel->getKeyName(), '<>', $model->getKey());
|
||||
}
|
||||
|
||||
if ($scopeMethod = $this->scope) {
|
||||
$query->$scopeMethod($model);
|
||||
}
|
||||
|
||||
// Even though "no constraints" is applied, belongsToMany constrains the query
|
||||
// by joining its pivot table. Remove all joins from the query.
|
||||
$query->getQuery()->getQuery()->joins = [];
|
||||
|
||||
if ($scopeMethod = $this->scope) {
|
||||
$query->$scopeMethod($model);
|
||||
}
|
||||
|
||||
// Determine if the model uses a tree trait
|
||||
$treeTraits = ['October\Rain\Database\Traits\NestedTree', 'October\Rain\Database\Traits\SimpleTree'];
|
||||
$usesTree = count(array_intersect($treeTraits, class_uses($relationModel))) > 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue