Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Blazik committed Oct 29, 2023
1 parent 3c7a44b commit f481eb7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Models/Scopes/MappedColumnsScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,18 @@ private function mapColumns($array, $mappedColToDbColWithTable)

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

$mappedColToDbColOnlyTables = array_filter(
$mappedColToDbColWithTable,
fn($val) => str_contains($val, '.')
);

$column['query']->columns = $this->mapColumns($column['query']->columns, $mappedColToDbColOnlyTables);
$column['query']->wheres = $this->mapColumns($column['query']->wheres, $mappedColToDbColOnlyTables);
$column['query']->joins = $this->mapJoins($column['query']->joins, $mappedColToDbColOnlyTables);

} elseif ($column['type'] === 'Column') {
if ($newColumnName = $mappedColToDbColWithTable[$column['first']] ?? null) {
$array[$key]['first'] = $newColumnName;
Expand Down

0 comments on commit f481eb7

Please sign in to comment.