From 3fdf2d99155c1077d0f13b1b13ed3419a2dffc75 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Fri, 21 Feb 2020 21:37:48 +0300 Subject: [PATCH] fixed exports --- app/Exports/Banking/Transactions.php | 2 +- app/Exports/Purchases/Sheets/BillHistories.php | 8 +++++++- app/Exports/Purchases/Sheets/BillItemTaxes.php | 8 +++++++- app/Exports/Purchases/Sheets/BillItems.php | 8 +++++++- app/Exports/Purchases/Sheets/BillTotals.php | 8 +++++++- app/Exports/Purchases/Sheets/BillTransactions.php | 8 +++++++- app/Exports/Sales/Sheets/InvoiceHistories.php | 8 +++++++- app/Exports/Sales/Sheets/InvoiceItemTaxes.php | 8 +++++++- app/Exports/Sales/Sheets/InvoiceItems.php | 8 +++++++- app/Exports/Sales/Sheets/InvoiceTotals.php | 8 +++++++- app/Exports/Sales/Sheets/InvoiceTransactions.php | 8 +++++++- 11 files changed, 71 insertions(+), 11 deletions(-) diff --git a/app/Exports/Banking/Transactions.php b/app/Exports/Banking/Transactions.php index 828ef3e3c..f153d8a0f 100644 --- a/app/Exports/Banking/Transactions.php +++ b/app/Exports/Banking/Transactions.php @@ -9,7 +9,7 @@ class Transactions extends Export { public function collection() { - $model = Model::with(['account', 'bill', 'category', 'contact', 'invoice'])->usingSearchString(request('search'))->get(); + $model = Model::with(['account', 'bill', 'category', 'contact', 'invoice'])->usingSearchString(request('search')); if (!empty($this->ids)) { $model->whereIn('id', (array) $this->ids); diff --git a/app/Exports/Purchases/Sheets/BillHistories.php b/app/Exports/Purchases/Sheets/BillHistories.php index 86b26b0f9..07746ea23 100644 --- a/app/Exports/Purchases/Sheets/BillHistories.php +++ b/app/Exports/Purchases/Sheets/BillHistories.php @@ -20,7 +20,13 @@ class BillHistories extends Export public function map($model): array { - $model->bill_number = $model->bill->bill_number; + $bill = $model->bill; + + if (empty($bill)) { + return []; + } + + $model->bill_number = $bill->bill_number; return parent::map($model); } diff --git a/app/Exports/Purchases/Sheets/BillItemTaxes.php b/app/Exports/Purchases/Sheets/BillItemTaxes.php index 7ceed7662..41977af0b 100644 --- a/app/Exports/Purchases/Sheets/BillItemTaxes.php +++ b/app/Exports/Purchases/Sheets/BillItemTaxes.php @@ -20,7 +20,13 @@ class BillItemTaxes extends Export public function map($model): array { - $model->bill_number = $model->bill->bill_number; + $bill = $model->bill; + + if (empty($bill)) { + return []; + } + + $model->bill_number = $bill->bill_number; $model->item_name = $model->item->name; $model->tax_rate = $model->tax->rate; diff --git a/app/Exports/Purchases/Sheets/BillItems.php b/app/Exports/Purchases/Sheets/BillItems.php index b131339f2..ba83c2871 100644 --- a/app/Exports/Purchases/Sheets/BillItems.php +++ b/app/Exports/Purchases/Sheets/BillItems.php @@ -20,7 +20,13 @@ class BillItems extends Export public function map($model): array { - $model->bill_number = $model->bill->bill_number; + $bill = $model->bill; + + if (empty($bill)) { + return []; + } + + $model->bill_number = $bill->bill_number; $model->item_name = $model->item->name; return parent::map($model); diff --git a/app/Exports/Purchases/Sheets/BillTotals.php b/app/Exports/Purchases/Sheets/BillTotals.php index 388574f5d..3846285dd 100644 --- a/app/Exports/Purchases/Sheets/BillTotals.php +++ b/app/Exports/Purchases/Sheets/BillTotals.php @@ -20,7 +20,13 @@ class BillTotals extends Export public function map($model): array { - $model->bill_number = $model->bill->bill_number; + $bill = $model->bill; + + if (empty($bill)) { + return []; + } + + $model->bill_number = $bill->bill_number; return parent::map($model); } diff --git a/app/Exports/Purchases/Sheets/BillTransactions.php b/app/Exports/Purchases/Sheets/BillTransactions.php index 7b19345fc..8d5069ee7 100644 --- a/app/Exports/Purchases/Sheets/BillTransactions.php +++ b/app/Exports/Purchases/Sheets/BillTransactions.php @@ -20,7 +20,13 @@ class BillTransactions extends Export public function map($model): array { - $model->bill_number = $model->bill->bill_number; + $bill = $model->bill; + + if (empty($bill)) { + return []; + } + + $model->bill_number = $bill->bill_number; $model->account_name = $model->account->name; $model->category_name = $model->category->name; $model->contact_email = $model->contact->email; diff --git a/app/Exports/Sales/Sheets/InvoiceHistories.php b/app/Exports/Sales/Sheets/InvoiceHistories.php index c31082d2e..2af6e260f 100644 --- a/app/Exports/Sales/Sheets/InvoiceHistories.php +++ b/app/Exports/Sales/Sheets/InvoiceHistories.php @@ -20,7 +20,13 @@ class InvoiceHistories extends Export public function map($model): array { - $model->invoice_number = $model->invoice->invoice_number; + $invoice = $model->invoice; + + if (empty($invoice)) { + return []; + } + + $model->invoice_number = $invoice->invoice_number; return parent::map($model); } diff --git a/app/Exports/Sales/Sheets/InvoiceItemTaxes.php b/app/Exports/Sales/Sheets/InvoiceItemTaxes.php index fac9553d7..1a128ac2d 100644 --- a/app/Exports/Sales/Sheets/InvoiceItemTaxes.php +++ b/app/Exports/Sales/Sheets/InvoiceItemTaxes.php @@ -20,7 +20,13 @@ class InvoiceItemTaxes extends Export public function map($model): array { - $model->invoice_number = $model->invoice->invoice_number; + $invoice = $model->invoice; + + if (empty($invoice)) { + return []; + } + + $model->invoice_number = $invoice->invoice_number; $model->item_name = $model->item->name; $model->tax_rate = $model->tax->rate; diff --git a/app/Exports/Sales/Sheets/InvoiceItems.php b/app/Exports/Sales/Sheets/InvoiceItems.php index 5705cb52c..e65dbdcca 100644 --- a/app/Exports/Sales/Sheets/InvoiceItems.php +++ b/app/Exports/Sales/Sheets/InvoiceItems.php @@ -20,7 +20,13 @@ class InvoiceItems extends Export public function map($model): array { - $model->invoice_number = $model->invoice->invoice_number; + $invoice = $model->invoice; + + if (empty($invoice)) { + return []; + } + + $model->invoice_number = $invoice->invoice_number; $model->item_name = $model->item->name; return parent::map($model); diff --git a/app/Exports/Sales/Sheets/InvoiceTotals.php b/app/Exports/Sales/Sheets/InvoiceTotals.php index 7c8ac4b43..9953d206f 100644 --- a/app/Exports/Sales/Sheets/InvoiceTotals.php +++ b/app/Exports/Sales/Sheets/InvoiceTotals.php @@ -20,7 +20,13 @@ class InvoiceTotals extends Export public function map($model): array { - $model->invoice_number = $model->invoice->invoice_number; + $invoice = $model->invoice; + + if (empty($invoice)) { + return []; + } + + $model->invoice_number = $invoice->invoice_number; return parent::map($model); } diff --git a/app/Exports/Sales/Sheets/InvoiceTransactions.php b/app/Exports/Sales/Sheets/InvoiceTransactions.php index b4d7f660d..36d058b39 100644 --- a/app/Exports/Sales/Sheets/InvoiceTransactions.php +++ b/app/Exports/Sales/Sheets/InvoiceTransactions.php @@ -20,7 +20,13 @@ class InvoiceTransactions extends Export public function map($model): array { - $model->invoice_number = $model->invoice->invoice_number; + $invoice = $model->invoice; + + if (empty($invoice)) { + return []; + } + + $model->invoice_number = $invoice->invoice_number; $model->account_name = $model->account->name; $model->category_name = $model->category->name; $model->contact_email = $model->contact->email;