24 lines
818 B
PHP
24 lines
818 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Staff;
|
|
|
|
use App\Domain\ACL\Permission;
|
|
use App\Domain\Report\ExportFormat;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\StudyReport;
|
|
use App\Services\Report\Export\Exporters;
|
|
use App\Services\Report\ReportStorage;
|
|
|
|
final class ReportDownloadController extends Controller
|
|
{
|
|
public function __invoke(string $uuid, string $format)
|
|
{
|
|
abort_unless(me()->may([Permission::ReportEdit, Permission::ReportDictate, Permission::ReportApprove, Permission::ReportDownload]), 403);
|
|
$report = StudyReport::with(['study', 'radiologist'])->where('accession_number', $uuid)->firstOrFail();
|
|
|
|
$path = Exporters::make($report->study, $report, ExportFormat::from(strtolower($format)));
|
|
|
|
return response()->download(ReportStorage::abspath($path));
|
|
}
|
|
}
|