diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 838bf1dd1b09..8a0013c6d8f9 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -206,8 +206,6 @@ class InvoiceController extends Controller $file = $invoice->service()->getInvoicePdf(auth()->guard('contact')->user()); - // return response()->download(file_get_contents(public_path($file))); - return response()->streamDownload(function () use ($file) { echo Storage::get($file); }, basename($file), ['Content-Type' => 'application/pdf']); diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 1baee4a081df..65783bb506e5 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -45,9 +45,13 @@ class PdfSlot extends Component private $entity_type; + public $download_button_text; + public function mount() { MultiDB::setDb($this->db); + + $this->download_button_text = ctrans('texts.download_pdf'); } public function getPdf() @@ -55,6 +59,25 @@ class PdfSlot extends Component $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); } + public function downloadPdf() + { + + $this->download_button_text = ctrans('texts.working'); + + $file_name = $this->entity->numberFormatter().'.pdf'; + + $file = (new \App\Jobs\Entity\CreateRawPdf($this->invitation, $this->invitation->company->db))->handle(); + + $headers = ['Content-Type' => 'application/pdf']; + + return response()->streamDownload(function () use ($file) { + echo $file; + }, $file_name, $headers); + + $this->download_button_text = ctrans('texts.download_pdf'); + + } + public function render() { $this->entity_type = $this->resolveEntityType(); diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php index 1f08f1d535e5..94b20c8d0dbb 100644 --- a/resources/views/portal/ninja2020/components/html-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -26,6 +26,7 @@ span { } +