Skip to content

Commit f481eb7

Browse files
committed
update
1 parent 3c7a44b commit f481eb7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Models/Scopes/MappedColumnsScope.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,18 @@ private function mapColumns($array, $mappedColToDbColWithTable)
4141

4242
foreach ($array as $key => $column) {
4343
if (is_array($column)) {
44-
if ($column['type'] === 'Exists') {
44+
if ($column['type'] === 'Exists' || $column['type'] === 'Nested') {
4545
$column['query']->applyBeforeQueryCallbacks();
4646

47+
$mappedColToDbColOnlyTables = array_filter(
48+
$mappedColToDbColWithTable,
49+
fn($val) => str_contains($val, '.')
50+
);
51+
52+
$column['query']->columns = $this->mapColumns($column['query']->columns, $mappedColToDbColOnlyTables);
53+
$column['query']->wheres = $this->mapColumns($column['query']->wheres, $mappedColToDbColOnlyTables);
54+
$column['query']->joins = $this->mapJoins($column['query']->joins, $mappedColToDbColOnlyTables);
55+
4756
} elseif ($column['type'] === 'Column') {
4857
if ($newColumnName = $mappedColToDbColWithTable[$column['first']] ?? null) {
4958
$array[$key]['first'] = $newColumnName;

0 commit comments

Comments
 (0)