Apply defined constraints to view mode
In the same way it is currently applied to manage mode Fixes #2292
This commit is contained in:
parent
c2d2250a1c
commit
618a035616
|
|
@ -621,10 +621,30 @@ class RelationController extends ControllerBehavior
|
|||
$config->noRecordsMessage = $emptyMessage;
|
||||
}
|
||||
|
||||
$widget = $this->makeWidget('Backend\Widgets\Lists', $config);
|
||||
|
||||
/*
|
||||
* Apply defined constraints
|
||||
*/
|
||||
if ($sqlConditions = $this->getConfig('view[conditions]')) {
|
||||
$widget->bindEvent('list.extendQueryBefore', function($query) use ($sqlConditions) {
|
||||
$query->whereRaw($sqlConditions);
|
||||
});
|
||||
}
|
||||
elseif ($scopeMethod = $this->getConfig('view[scope]')) {
|
||||
$widget->bindEvent('list.extendQueryBefore', function($query) use ($scopeMethod) {
|
||||
$query->$scopeMethod();
|
||||
});
|
||||
}
|
||||
else {
|
||||
$widget->bindEvent('list.extendQueryBefore', function($query) {
|
||||
$this->relationObject->addDefinedConstraintsToQuery($query);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Constrain the query by the relationship and deferred items
|
||||
*/
|
||||
$widget = $this->makeWidget('Backend\Widgets\Lists', $config);
|
||||
$widget->bindEvent('list.extendQuery', function ($query) {
|
||||
$this->relationObject->setQuery($query);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue