Enth\u00e4lt gemischt: Laravel-10-Upgrade + Phase 1 (Contacts-Modul, Duplicats-Commands, Soft-Delete+Merge-Fields) + Phase 2 Code-Umstellungen (inquiry_id, $table='contacts'/'inquiries') + Offers-Modul (Migrationen, Models, offer_id in Booking, offer-Disk in filesystems.php). Phase 2 + Offers werden im folgenden Commit nach dev/backups/phase2-offers-2026-04-17/ verschoben, damit der Workspace auf Phase-1-only (= Test-System-Stand) reduziert ist und direkt auf Live deploybar wird. Tarball-Backup zus\u00e4tzlich unter: ../backups-safety/workspace-pre-phase1-rollback-2026-04-17.tar.gz Made-with: Cursor
63 lines
1.5 KiB
PHP
63 lines
1.5 KiB
PHP
<?php
|
|
namespace App\Libraries;
|
|
|
|
use App\Libraries\CouponPDF;
|
|
use App\Models\Coupon;
|
|
use Storage;
|
|
|
|
class CreatePDF{
|
|
|
|
protected $view;
|
|
protected $pdf;
|
|
protected $prepath;
|
|
protected $disk;
|
|
|
|
|
|
public function __construct($view, $disk = 'public')
|
|
{
|
|
$this->view = $view;
|
|
$this->disk = $disk;
|
|
$this->prepath = Storage::disk($disk)->path('');
|
|
|
|
}
|
|
|
|
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'){
|
|
//file???
|
|
return $pdf->stream($name);
|
|
}
|
|
if($output === 'download'){
|
|
//download
|
|
return $pdf->download($name);
|
|
}
|
|
|
|
if($output === 'save'){
|
|
if($path){
|
|
$pdf->save($path.$name);
|
|
return $path.$name;
|
|
}
|
|
}
|
|
}
|
|
|
|
public function merger($dir, $filename, $template){
|
|
$pdfMerger = new MyPDFMerger();
|
|
$pdfMerger->addPDF($this->prepath.$dir.$filename);
|
|
$file = $pdfMerger->myMerge('string', $filename, $template);
|
|
Storage::disk($this->disk)->put($dir.$filename, $file);
|
|
}
|
|
|
|
public function setPrePath($path){
|
|
$this->prepath = $path;
|
|
}
|
|
|
|
}
|
|
?>
|