28 lines
683 B
PHP
28 lines
683 B
PHP
<?php
|
|
|
|
namespace App\Services\DocumentGenerator;
|
|
|
|
use App\Models\Study;
|
|
use App\Models\StudyReport;
|
|
use App\Services\ReportStorage;
|
|
use CreateDocx;
|
|
|
|
final readonly class Word
|
|
{
|
|
public static function make(Study $study, StudyReport $report): string
|
|
{
|
|
$filename = $report->accession_number . '.docx';
|
|
$filepath = ReportStorage::customFilepath($study, $filename);
|
|
if (ReportStorage::exists($study, $filename)) {
|
|
return $filepath;
|
|
}
|
|
|
|
$html = $report->getContent();
|
|
$docx = new CreateDocx;
|
|
$docx->embedHTML($html);
|
|
$docx->createDocx(ReportStorage::abspath($filepath));
|
|
|
|
return $filepath;
|
|
}
|
|
}
|