From b85afd032ab1b2080c57f058f408aacff64705a7 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Mon, 20 Jan 2025 11:16:16 -0600 Subject: [PATCH] Fix division by 0 issue in scoring --- .../Admin/ExportEntriesController.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 app/Http/Controllers/Admin/ExportEntriesController.php diff --git a/app/Http/Controllers/Admin/ExportEntriesController.php b/app/Http/Controllers/Admin/ExportEntriesController.php new file mode 100644 index 0000000..d569c0a --- /dev/null +++ b/app/Http/Controllers/Admin/ExportEntriesController.php @@ -0,0 +1,37 @@ +getData(); + // Create a callback to write the CSV data + $callback = function () use ($data) { + $file = fopen('php://output', 'w'); + + foreach ($data as $line) { + // Convert the string into an array + $fields = explode(',', $line); + // Write the array to the CSV file + fputcsv($file, $fields); + } + + fclose($file); + }; + + // Return a response with the CSV content + return Response::stream($callback, 200, [ + 'Content-Type' => 'text/csv', + 'Content-Disposition' => 'attachment; filename="audition_entries_export.csv"', + ]); + + } +}