35 lines
962 B
PHP
35 lines
962 B
PHP
<?php
|
|
|
|
namespace app\Services\Export\Formats;
|
|
|
|
use App\Domain\Report\ExportFormat;
|
|
use App\Services\Export\ExportDocumentBase;
|
|
use App\Services\Report\ReportStorage;
|
|
use Barryvdh\DomPDF\Facade\Pdf;
|
|
|
|
final class PdfExport extends ExportDocumentBase
|
|
{
|
|
protected function handle(): string
|
|
{
|
|
$filename = $this->filename();
|
|
$filepath = ReportStorage::customFilepath($this->study, $filename);
|
|
if (ReportStorage::exists($this->study, $filename)) {
|
|
return $filepath;
|
|
}
|
|
|
|
$data = ['report' => $this->report, 'title' => 'PDF VIEW'];
|
|
Pdf::loadView('staff.reports.viewer.html-report', $data)
|
|
->setPaper('a4', 'landscape')
|
|
->setWarnings(false)
|
|
->setOption('defaultFont', 'Courier')
|
|
->save(ReportStorage::abspath($filepath));
|
|
|
|
return $filepath;
|
|
}
|
|
|
|
protected function getExtension(): string
|
|
{
|
|
return ExportFormat::Pdf->value;
|
|
}
|
|
}
|