<?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);
    }
}