Skip to content

Commit bdc2332

Browse files
committed
Refactor CSV export in ExportTemplateCmsBri action to remove unnecessary enclosures and streamline data writing process
1 parent 6f1c374 commit bdc2332

File tree

2 files changed

+5
-30
lines changed

2 files changed

+5
-30
lines changed

app/Nova/Actions/ExportTemplateCmsBri.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,21 +172,21 @@ public function handle(ActionFields $fields, Collection $models)
172172
(new FastExcel($collection))->configureCsv(delimiter: '|')->export(Storage::disk('temp')->path($filename));
173173
$inputFile = Storage::disk('temp')->path($filename);
174174
$outputFile = Storage::disk('temp')->path('clean_'.$filename);
175-
175+
176176
$inputHandle = fopen($inputFile, 'r');
177177
$outputHandle = fopen($outputFile, 'w');
178-
178+
179179
if ($inputHandle !== false && $outputHandle !== false) {
180180
while (($data = fgetcsv($inputHandle, 0, '|', '"')) !== false) {
181-
// Gabungkan data dengan koma tanpa enclosure dan tulis ke file baru
182-
fwrite($outputHandle, implode('|', $data) . PHP_EOL);
181+
fwrite($outputHandle, implode('|', $data).PHP_EOL);
183182
}
184183
fclose($inputHandle);
185184
fclose($outputHandle);
186185
}
187-
186+
188187
Storage::disk('temp')->delete($filename);
189188
Storage::disk('temp')->move('clean_'.$filename, $filename);
189+
190190
return Action::redirect(route('dump-download', [
191191
'filename' => $filename,
192192
]));

storage/app/public/.temp/67b3bd06d2597.csv

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)