From e7f04f0cf880c7f87fb211e26f0ab9ce59df34a9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 6 Oct 2023 22:35:54 +1100 Subject: [PATCH] pass result, not collect --- app/Services/Template/TemplateAction.php | 14 +++++++------- tests/Feature/InvoiceTest.php | 2 -- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/Services/Template/TemplateAction.php b/app/Services/Template/TemplateAction.php index b8cce0f74809..80f0a3351e12 100644 --- a/app/Services/Template/TemplateAction.php +++ b/app/Services/Template/TemplateAction.php @@ -85,16 +85,16 @@ class TemplateAction implements ShouldQueue $resource->with('payments', 'client'); } - $resource->withTrashed() + $result = $resource->withTrashed() ->whereIn('id', $this->transformKeys($this->ids)) - ->where('company_id', $this->company->id); + ->where('company_id', $this->company->id) + ->get(); - $resource->get(); - - if($resource->count() <= 1) - $data[$key] = [$resource]; + + if($result->count() <= 1) + $data[$key] = collect($result); else - $data[$key] = $resource; + $data[$key] = $result; $pdf = $template_service->build($data)->getPdf(); diff --git a/tests/Feature/InvoiceTest.php b/tests/Feature/InvoiceTest.php index e54c6c2e2580..a97515484ce1 100644 --- a/tests/Feature/InvoiceTest.php +++ b/tests/Feature/InvoiceTest.php @@ -87,8 +87,6 @@ class InvoiceTest extends TestCase false))->handle(); } - - public function testInvoiceGetDatesBetween() { $response = $this->withHeaders([