Добавил pdf шаблон и выгрузку

This commit is contained in:
brusnitsyn
2026-06-22 17:01:59 +09:00
parent 09f5e0d686
commit bdb16dac54
2 changed files with 63 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Services\Analytics\Export;
use App\Services\Analytics\AnalyticsResult;
use Barryvdh\DomPDF\Facade\Pdf;
use Barryvdh\DomPDF\PDF as PdfDocument;
class AnalyticsPdfExport
{
public static function render(AnalyticsResult $result, string $title): PdfDocument
{
return Pdf::loadView('reports.analytics_pdf', [
'title' => $title,
'columns' => array_map(fn ($c) => $c->toArray(), $result->columns),
'rows' => $result->rows,
'generatedAt' => now('Asia/Yakutsk')->format('d.m.Y H:i'),
])->setPaper('a4', 'landscape');
}
}