Добавил pdf шаблон и выгрузку
This commit is contained in:
20
app/Services/Analytics/Export/AnalyticsPdfExport.php
Normal file
20
app/Services/Analytics/Export/AnalyticsPdfExport.php
Normal 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user