Skip to content

Commit c856da6

Browse files
Merge pull request #2200 from suraj-webkul/issue#2172-unnecessay-label
Issue #2172 has been fixed.
2 parents 8891af8 + 1a1ccd9 commit c856da6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/Webkul/DataGrid/src/Exports/DataGridExport.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public function map(mixed $record): array
4747
$index = $column->getIndex();
4848
$value = $record->{$index};
4949

50-
if (in_array($index, ['emails', 'contact_numbers']) && is_string($value)) {
50+
if (
51+
in_array($index, ['emails', 'contact_numbers'])
52+
&& is_string($value)
53+
) {
5154
return $this->extractValuesFromJson($value);
5255
}
5356

@@ -61,11 +64,13 @@ public function map(mixed $record): array
6164
*/
6265
protected function extractValuesFromJson(string $json): string
6366
{
64-
$decoded = json_decode($json, true);
67+
$items = json_decode($json, true);
6568

66-
if (json_last_error() === JSON_ERROR_NONE
67-
&& is_array($decoded)) {
68-
return collect($decoded)->pluck('value')->implode(', ');
69+
if (
70+
json_last_error() === JSON_ERROR_NONE
71+
&& is_array($items)
72+
) {
73+
return collect($items)->map(fn ($item) => "{$item['value']} ({$item['label']})")->implode(', ');
6974
}
7075

7176
return $json;

0 commit comments

Comments
 (0)