From 336eb1300322413a4459c3f3a5d54dfb690b81c4 Mon Sep 17 00:00:00 2001 From: emissarman <31867058+emissarman@users.noreply.github.com> Date: Tue, 20 Feb 2024 23:17:49 +0300 Subject: [PATCH] fix summaries formatter --- src/ProcessDataSource.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ProcessDataSource.php b/src/ProcessDataSource.php index 1ba8db0e..28257801 100644 --- a/src/ProcessDataSource.php +++ b/src/ProcessDataSource.php @@ -347,6 +347,7 @@ private function applySummaries(MorphToMany|EloquentBuilder|BaseCollection|Query return; } + $formatterFound = false; foreach ($summarizeFormat as $field => $format) { $parts = explode('.', $field); @@ -354,11 +355,16 @@ private function applySummaries(MorphToMany|EloquentBuilder|BaseCollection|Query $formats = str($parts[1])->replace(['{', '}'], ''); $allowedSummarizeFormats = explode(',', $formats); - if (in_array($summarize, $allowedSummarizeFormats)) { + if ($column->field === $parts[0] && in_array($summarize, $allowedSummarizeFormats)) { + $formatterFound = true; data_set($column, 'summarize.' . $summarize, $this->component->summarizeFormat()[$field]($value)); } } } + + if (!$formatterFound) { + data_set($column, 'summarize.' . $summarize, $value); + } } };