This commit is contained in:
2025-05-27 02:35:05 +05:00
parent bf69695439
commit c37391f165

View File

@@ -60,7 +60,12 @@ class DownloadCardTransaction extends Action
return ActionResponse::danger($data->message); return ActionResponse::danger($data->message);
} }
$this->generateFile($data); $unique_folder_id = Str::snake($model->created_at->toDateTimeString());
$fileDest = public_path("files/{$unique_folder_id}/{$model->id}.pdf");
$this->generateFile($data, $fileDest);
return ActionResponse::openInNewTab(url("files/{$unique_folder_id}/{$model->id}.pdf"));
} }
/** /**
@@ -128,8 +133,9 @@ class DownloadCardTransaction extends Action
* Generate file * Generate file
* *
* @param ResponseTypes\AzatApiClientInfoAllResponse $data * @param ResponseTypes\AzatApiClientInfoAllResponse $data
* @param string $fileDest
*/ */
public function generateFile($data) public function generateFile($data, $fileDest)
{ {
$mpdf = new Mpdf; $mpdf = new Mpdf;
@@ -141,6 +147,6 @@ class DownloadCardTransaction extends Action
$mpdf->WriteHTML($html); $mpdf->WriteHTML($html);
// Save the PDF to a file // Save the PDF to a file
$mpdf->Output(public_path('files/output.pdf'), \Mpdf\Output\Destination::FILE); $mpdf->Output($fileDest, \Mpdf\Output\Destination::FILE);
} }
} }