wip
This commit is contained in:
@@ -61,16 +61,9 @@ class DownloadCardTransaction extends Action
|
||||
return ActionResponse::danger($data->message);
|
||||
}
|
||||
|
||||
$unique_folder_name = Str::snake(str_replace(':', '-', $model->created_at->toDateTimeString()));
|
||||
$dir = public_path("files/{$unique_folder_name}");
|
||||
$url = $this->doFiles($model, $data);
|
||||
|
||||
File::makeDirectory($dir, 0777, true, true);
|
||||
|
||||
$fileDest = $dir."/{$model->id}.pdf";
|
||||
|
||||
$this->generateFile($data, $fileDest);
|
||||
|
||||
return ActionResponse::openInNewTab(url("files/{$unique_folder_name}/{$model->id}.pdf"));
|
||||
return ActionResponse::openInNewTab($url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,6 +87,26 @@ class DownloadCardTransaction extends Action
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles all file stuff
|
||||
*
|
||||
* @param $model
|
||||
* @param $data
|
||||
*/
|
||||
public function doFiles($model, $data): string
|
||||
{
|
||||
$unique_folder_name = Str::snake(str_replace(':', '-', $model->created_at->toDateTimeString()));
|
||||
$dir = public_path("files/{$unique_folder_name}");
|
||||
|
||||
File::makeDirectory($dir, 0777, true, true);
|
||||
|
||||
$fileDest = $dir."/{$model->id}.pdf";
|
||||
|
||||
$this->generateFile($data, $fileDest);
|
||||
|
||||
return url("files/{$unique_folder_name}/{$model->id}.pdf");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch from internal API
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user