From d3372680cf773e8369c8b2a314f17b583cb00730 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 3 Jun 2016 11:17:55 +0300 Subject: [PATCH] Include archived records in JSON export --- app/Http/Controllers/ExportController.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 114c52a110ab..d38f492486ae 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -42,8 +42,17 @@ class ExportController extends BaseController $manager = new Manager(); $manager->setSerializer(new ArraySerializer()); + // eager load data, include archived but exclude deleted $account = Auth::user()->account; - $account->load(['clients.contacts', 'clients.invoices.payments', 'clients.invoices.invoice_items']); + $account->load(['clients' => function($query) { + $query->withArchived() + ->with(['contacts', 'invoices' => function($query) { + $query->withArchived() + ->with(['invoice_items', 'payments' => function($query) { + $query->withArchived(); + }]); + }]); + }]); $resource = new Item($account, new AccountTransformer); $data = $manager->parseIncludes('clients.invoices.payments')