mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Add support for morphOne relations in backend list columns (#4079)
Fixes #4078. Credit to @SeriousKen
This commit is contained in:
parent
da8073c945
commit
15bfcf8cfd
@ -350,6 +350,7 @@ class Lists extends WidgetBase
|
||||
$selects = [$primaryTable.'.*'];
|
||||
$joins = [];
|
||||
$withs = [];
|
||||
$bindings = [];
|
||||
|
||||
/**
|
||||
* @event backend.list.extendQueryBefore
|
||||
@ -501,6 +502,11 @@ class Lists extends WidgetBase
|
||||
$joinSql = $countQuery->select($joinSql)->toSql();
|
||||
|
||||
$selects[] = Db::raw("(".$joinSql.") as ".$alias);
|
||||
|
||||
/*
|
||||
* If this is a polymorphic relation there will be bindings that need to be added to the query
|
||||
*/
|
||||
$bindings = array_merge($bindings, $countQuery->getBindings());
|
||||
}
|
||||
/*
|
||||
* Primary column
|
||||
@ -540,6 +546,11 @@ class Lists extends WidgetBase
|
||||
* Add custom selects
|
||||
*/
|
||||
$query->addSelect($selects);
|
||||
|
||||
/*
|
||||
* Add bindings for polymorphic relations
|
||||
*/
|
||||
$query->addBinding($bindings, 'select');
|
||||
|
||||
/**
|
||||
* @event backend.list.extendQuery
|
||||
|
Loading…
x
Reference in New Issue
Block a user