Fix division by 0 issue in scoring
This commit is contained in:
parent
a8ab2cef73
commit
b85afd032a
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Actions\Reports\ExportEntryData;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Support\Facades\Response;
|
||||||
|
|
||||||
|
class ExportEntriesController extends Controller
|
||||||
|
{
|
||||||
|
public function __invoke()
|
||||||
|
{
|
||||||
|
$exporter = App::make(ExportEntryData::class);
|
||||||
|
$data = $exporter->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"',
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue