生成pdf

This commit is contained in:
2026-01-09 15:03:30 +08:00
parent 620ef3fe3a
commit 4a1e243726
6 changed files with 105 additions and 9 deletions
+21
View File
@@ -94,6 +94,9 @@ class UsedCarService
if(empty($data['price'])){
$data['price'] = 0;
}
if(!empty($data['attachment'])){
$data['attachment'] = json_encode($data['attachment']);
}
$data['user_id'] = $request->user['id'];
return $data;
}
@@ -268,4 +271,22 @@ class UsedCarService
return $path;
}
function downloadAttachment(string $url): string
{
$dir = runtime_path('pdf/attachment/');
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
$filename = md5($url) . '.pdf';
$path = $dir . $filename;
if (!file_exists($path)) {
$img = file_get_contents($url);
file_put_contents($path, $img);
}
return $path;
}
}