From e17af36cf4309526acaf188765361792fbdedccd Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 19 Oct 2023 07:34:40 +1100 Subject: [PATCH] Improvements for live preview --- app/Http/Controllers/PreviewController.php | 8 +++----- app/Http/Requests/Preview/PreviewInvoiceRequest.php | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 6777af3f941d..2797bae0eea1 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -61,11 +61,11 @@ class PreviewController extends BaseController } private function purgeCache() - { nlog(auth()->user()->id); + { Cache::pull("preview_".auth()->user()->id); } - public function newLivePreview(PreviewInvoiceRequest $request) + public function live(PreviewInvoiceRequest $request) { $time = time(); @@ -153,8 +153,6 @@ class PreviewController extends BaseController $pdf = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle(); - nlog("merpy derp {$time}"); - return response()->streamDownload(function () use ($pdf) { echo $pdf; }, 'preview.pdf', ['Content-Type' => 'application/pdf','Cache-Control:' => 'no-cache']); @@ -273,7 +271,7 @@ class PreviewController extends BaseController return $response; } - public function live(PreviewInvoiceRequest $request) + public function livex(PreviewInvoiceRequest $request) { // if(Cache::has("preview_".auth()->user()->id)) diff --git a/app/Http/Requests/Preview/PreviewInvoiceRequest.php b/app/Http/Requests/Preview/PreviewInvoiceRequest.php index 50cc0a7fdf73..2188efa37c98 100644 --- a/app/Http/Requests/Preview/PreviewInvoiceRequest.php +++ b/app/Http/Requests/Preview/PreviewInvoiceRequest.php @@ -92,10 +92,10 @@ class PreviewInvoiceRequest extends Request return $this->stubInvitation(); match($this->entity){ - 'invoice' => $invitation = Invoice::withTrashed()->where('invoice_id', $this->entity_id)->first(), - 'quote' => $invitation = Quote::withTrashed()->where('quote_id', $this->entity_id)->first(), - 'credit' => $invitation = Credit::withTrashed()->where('credit_id', $this->entity_id)->first(), - 'recurring_invoice' => $invitation = RecurringInvoice::withTrashed()->where('recurring_invoice_id', $this->entity_id)->first(), + 'invoice' => $invitation = InvoiceInvitation::withTrashed()->where('invoice_id', $this->entity_id)->first(), + 'quote' => $invitation = QuoteInvitation::withTrashed()->where('quote_id', $this->entity_id)->first(), + 'credit' => $invitation = CreditInvitation::withTrashed()->where('credit_id', $this->entity_id)->first(), + 'recurring_invoice' => $invitation = RecurringInvoiceInvitation::withTrashed()->where('recurring_invoice_id', $this->entity_id)->first(), }; if($invitation)