@@ -45,14 +45,11 @@ protected function buildColumnByCollection(array $row, Collection $columns, stri
45
45
$ key = $ column ->data ?? $ column ->name ;
46
46
}
47
47
48
- /** @var string $data */
49
48
$ data = Arr::get ($ row , $ key ) ?? '' ;
50
49
51
50
if ($ type == 'exportable ' ) {
52
51
$ title = $ this ->decodeContent ($ title );
53
- $ dataType = gettype ($ data );
54
- $ data = $ this ->decodeContent ($ data );
55
- settype ($ data , $ dataType );
52
+ $ data = is_array ($ data ) ? json_encode ($ data ) : $ this ->decodeContent ($ data );
56
53
}
57
54
58
55
$ results [$ title ] = $ data ;
@@ -65,17 +62,21 @@ protected function buildColumnByCollection(array $row, Collection $columns, stri
65
62
/**
66
63
* Decode content to a readable text value.
67
64
*
68
- * @param bool|string $data
69
- * @return string
65
+ * @param mixed $data
66
+ * @return mixed
70
67
*/
71
- protected function decodeContent (bool | string $ data ): string
68
+ protected function decodeContent (mixed $ data ): mixed
72
69
{
73
70
if (is_bool ($ data )) {
74
71
return $ data ? 'True ' : 'False ' ;
75
72
}
76
73
77
- $ decoded = html_entity_decode (trim (strip_tags ($ data )), ENT_QUOTES , 'UTF-8 ' );
74
+ if (is_string ($ data )) {
75
+ $ decoded = html_entity_decode (trim (strip_tags ($ data )), ENT_QUOTES , 'UTF-8 ' );
78
76
79
- return str_replace ("\xc2\xa0" , ' ' , $ decoded );
77
+ return (string ) str_replace ("\xc2\xa0" , ' ' , $ decoded );
78
+ }
79
+
80
+ return $ data ;
80
81
}
81
82
}
0 commit comments