Update Framework, Invoices
This commit is contained in:
parent
cc5c147c27
commit
9b0b5feb7e
174 changed files with 28356 additions and 8093 deletions
45
app/Libraries/InvoicePDF.php
Normal file
45
app/Libraries/InvoicePDF.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
namespace App\Libraries;
|
||||
|
||||
use App\Libraries\CouponPDF;
|
||||
use App\Models\Coupon;
|
||||
use Storage;
|
||||
|
||||
class InvoicePDF{
|
||||
|
||||
protected $view;
|
||||
protected $pdf;
|
||||
|
||||
|
||||
public function __construct($view)
|
||||
{
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function create($data, $name='test.pdf', $output='stream', $path = false){
|
||||
|
||||
header('Content-type: text/html; charset=UTF-8') ;//chrome
|
||||
//dd($data);
|
||||
|
||||
$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);
|
||||
}
|
||||
if($output === 'download'){
|
||||
return $pdf->download($name);
|
||||
}
|
||||
|
||||
if($output === 'save'){
|
||||
if($path){
|
||||
$pdf->save($path.$name);
|
||||
return $path.$name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue