Passolution

This commit is contained in:
Kevin Adametz 2020-10-16 16:18:34 +02:00
parent f79806ffe8
commit 06fc3ba919
31 changed files with 337 additions and 119 deletions

View file

@ -3,6 +3,7 @@ namespace App\Services;
use App\Libraries\CouponPDF;
use App\Models\Coupon;
use Storage;
class CreatePDF{
@ -15,20 +16,16 @@ class CreatePDF{
$this->view = $view;
}
public function create($fewo, $contents, $name='test.pdf', $output='stream'){
public function create($data, $name='test.pdf', $output='stream', $path = false){
header('Content-type: text/html; charset=UTF-8') ;//chrome
//dd($data);
$data = [
'contents' => $contents,
'fewo' => $fewo,
];
$pdf = app('dompdf.wrapper');
$pdf->getDomPDF()->set_option("enable_php", true);
$pdf->loadView($this->view, $data);
$pdf->setPaper('A4', 'portrait');
if($output === 'stream'){
return $pdf->stream($name);
}
@ -37,22 +34,10 @@ class CreatePDF{
}
if($output === 'save'){
/* $dir = $invoice->getInvoiceStorageDir();
if(!Storage::disk('invoices')->exists( $dir )){
Storage::disk('invoices')->makeDirectory($dir); //creates directory
}
$path = Storage::disk('invoices')->getAdapter()->getPathPrefix();
if($preview){
$filename = "preview.pdf";
}else{
$filename = $invoice->invoice_number.".pdf";
}
$pdf->save($path.$dir.$filename);
return $path.$dir.$filename; */
//return $pdf->download($name);
if($path){
$pdf->save($path.$name);
return $path.$name;
}
}
}