生成pdf
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user