radfusion/app/Services/Export/Formats/HtmlExport.php
2025-01-11 11:28:35 +06:00

32 lines
873 B
PHP

<?php
namespace app\Services\Export\Formats;
use App\Domain\Report\ExportFormat;
use App\Services\Export\ExportDocumentBase;
use App\Services\Report\ReportStorage;
use Illuminate\Support\Facades\Blade;
final class HtmlExport extends ExportDocumentBase
{
protected function handle(): string
{
$filename = $this->filename();
$filepath = ReportStorage::customFilepath($this->study, $filename);
if (ReportStorage::exists($this->study, $filename)) {
return $filepath;
}
$title = 'View Report';
$html = Blade::render('staff.reports.viewer.html-report', ['report' => $this->report, 'title' => $title]);
file_put_contents(ReportStorage::abspath($filepath), $html);
return $filepath;
}
protected function getExtension(): string
{
return ExportFormat::Html->value;
}
}