From a790101f3477f1a72078588271456ebbe7d8a064 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 6 Aug 2023 15:26:33 +1000 Subject: [PATCH] Fixes for previews --- app/Http/Controllers/PreviewController.php | 6 +++++- app/Services/Pdf/PdfMock.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 4ff7f3dabc..13a5daf431 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -210,12 +210,16 @@ class PreviewController extends BaseController if ($request->has('entity_id')) { /** @var \App\Models\Quote | \App\Models\Invoice | \App\Models\RecurringInvoice | \App\Models\Credit $class */ - $entity_obj = $class::on(config('database.default')) + $temp_obj = $class::on(config('database.default')) ->with('client.company') ->where('id', $this->decodePrimaryKey($request->input('entity_id'))) ->where('company_id', $company->id) ->withTrashed() ->first(); + + /** Prevents null values from being passed into entity_obj */ + if($temp_obj) + $entity_obj = $temp_obj; } if ($request->has('footer') && !$request->filled('footer') && $request->input('entity') == 'recurring_invoice') { diff --git a/app/Services/Pdf/PdfMock.php b/app/Services/Pdf/PdfMock.php index ade1e5d369..67ceaa42d8 100644 --- a/app/Services/Pdf/PdfMock.php +++ b/app/Services/Pdf/PdfMock.php @@ -103,7 +103,7 @@ class PdfMock switch ($this->request['entity_type']) { case 'invoice': - /** @var \App\Models\Invoice | \App\Models\Credit | \App\Models\Quote $entity */ + /** @var \App\Models\Invoice | \App\Models\Credit | \App\Models\Quote $entity */ $entity = Invoice::factory()->make(); $entity->client = Client::factory()->make(['settings' => $settings]); $entity->invitation = InvoiceInvitation::factory()->make();