@@ -127,10 +127,6 @@ public function handle(): void
127
127
128
128
$ row = $ row instanceof Arrayable ? $ row ->toArray () : (array ) $ row ;
129
129
130
- if ($ this ->usesLazyMethod () && is_array ($ row )) {
131
- $ row = Arr::dot ($ row );
132
- }
133
-
134
130
$ defaultDateFormat = 'yyyy-mm-dd ' ;
135
131
if (config ('datatables-export.default_date_format ' )
136
132
&& is_string (config ('datatables-export.default_date_format ' ))
@@ -147,7 +143,7 @@ public function handle(): void
147
143
}
148
144
149
145
/** @var array|bool|int|string|null|DateTimeInterface $value */
150
- $ value = $ row[ $ property] ?? '' ;
146
+ $ value = $ this -> getValue ( $ row, $ property) ?? '' ;
151
147
152
148
if (isset ($ column ->exportRender )) {
153
149
$ callback = $ column ->exportRender ;
@@ -231,6 +227,23 @@ protected function getExportableColumns(DataTable $dataTable): Collection
231
227
return $ columns ->filter (fn (Column $ column ) => $ column ->exportable );
232
228
}
233
229
230
+ protected function getValue (array $ row , string $ property ): mixed
231
+ {
232
+ [$ currentProperty , $ glue , $ childProperty ] = array_pad (preg_split ('/\[(.*?)\]\.?/ ' , $ property , 2 , PREG_SPLIT_DELIM_CAPTURE ), 3 , null );
233
+
234
+ if ($ glue === '' ) {
235
+ $ glue = ', ' ;
236
+ }
237
+
238
+ $ value = Arr::get ($ row , $ currentProperty );
239
+
240
+ if ($ childProperty ) {
241
+ $ value = Arr::map ($ value , fn ($ v ) => $ this ->getValue ($ v , $ childProperty ));
242
+ }
243
+
244
+ return $ glue ? Arr::join ($ value , $ glue ) : $ value ;
245
+ }
246
+
234
247
protected function usesLazyMethod (): bool
235
248
{
236
249
return config ('datatables-export.method ' , 'lazy ' ) === 'lazy ' ;
0 commit comments