Files
construprogress/app/Services/Report/ExcelExporter.php
T

20 lines
566 B
PHP
Raw Normal View History

<?php
namespace App\Services\Report;
use App\Models\Project;
use App\DTO\ReportFilters;
use Maatwebsite\Excel\Facades\Excel;
use App\Exports\ProjectReportExport;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class ExcelExporter
{
public function export(Project $project, ReportFilters $filters, array $data): BinaryFileResponse
{
$export = new ProjectReportExport($project, $filters, $data);
$filename = 'informe_'.$project->name.'_'.now()->format('Ymd_His').'.xlsx';
return Excel::download($export, $filename);
}
}