From 02a85cfc5a423c44e457ab22196d04bb19269b7e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 6 Oct 2023 22:21:58 +1100 Subject: [PATCH] Fixes for missing payments --- app/Services/Template/TemplateAction.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Services/Template/TemplateAction.php b/app/Services/Template/TemplateAction.php index bc4188d3b1..b8cce0f748 100644 --- a/app/Services/Template/TemplateAction.php +++ b/app/Services/Template/TemplateAction.php @@ -75,23 +75,23 @@ class TemplateAction implements ShouldQueue $key = $this->resolveEntityString(); - $entity = new $this->entity(); + $resource = $this->entity::query(); $template = Design::withTrashed()->find($this->decodePrimaryKey($this->template)); $template_service = new TemplateService($template); - $resource = $entity->query() - ->withTrashed() - ->whereIn('id', $this->transformKeys($this->ids)) - ->where('company_id', $this->company->id); + if($this->entity == Invoice::class) { + $resource->with('payments', 'client'); + } - if($this->entity == Invoice::class) - $resource->with('payments','client'); + $resource->withTrashed() + ->whereIn('id', $this->transformKeys($this->ids)) + ->where('company_id', $this->company->id); $resource->get(); - if(count($resource) <= 1) + if($resource->count() <= 1) $data[$key] = [$resource]; else $data[$key] = $resource;