Skip to content

Commit

Permalink
Fixes for Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alloylab committed Dec 20, 2024
1 parent d31d8cb commit 21a94b6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/DataSource/Processors/DataSourceBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,19 @@ protected function applySummaries(MorphToMany|EloquentBuilder|BaseCollection|Que
throw new \InvalidArgumentException('Summary Formatter expects a callable function, ' . gettype($formattingClosure) . ' given instead.');
}

if (in_array($fieldName, [$column['field'], $column['dataField']])) {
if (in_array($fieldName, [$column->field, $column->dataField])) {
$value = $formattingClosure($value);
}

data_set($column, 'properties.summarize_values.' . $summarizeMethod, $value);
}
}

return $column;
}
};

$this->component->columns = collect($this->component->columns)
->map(function (array|\stdClass|Column $column) use ($results, $applySummaryFormat) {
$column = (array) $column;
$column = (object) $column;

$field = strval(data_get($column, 'dataField')) ?: strval(data_get($column, 'field'));

Expand All @@ -252,8 +250,7 @@ protected function applySummaries(MorphToMany|EloquentBuilder|BaseCollection|Que
foreach ($summaries as $summary) {
if (data_get($column, 'properties.summarize.' . $summary . '.header') || data_get($column, 'properties.summarize.' . $summary . '.footer')) {
$value = $results->{$summary}($field);
$newColumn = rescue(fn () => $applySummaryFormat($summary, $column, $field, $value), report: false);
$column = is_null($newColumn) ? $column : $newColumn;
rescue(fn () => $applySummaryFormat($summary, $column, $field, $value), report: false);
}
}

Expand Down

0 comments on commit 21a94b6

Please sign in to comment.