From 06807275b99f78a95e82a32a442a351953ebc3b6 Mon Sep 17 00:00:00 2001 From: Mohit Panjwani Date: Sat, 23 Nov 2019 11:54:35 +0530 Subject: [PATCH] fix item reports issue --- app/Http/Controllers/ReportController.php | 3 +-- app/InvoiceItem.php | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 99d66027..cafaf44a 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -83,8 +83,7 @@ class ReportController extends Controller { $company = Company::where('unique_hash', $hash)->first(); - $items = InvoiceItem::with('item') - ->whereCompany($company->id) + $items = InvoiceItem::whereCompany($company->id) ->applyInvoiceFilters($request->only(['from_date', 'to_date'])) ->itemAttributes() ->get(); diff --git a/app/InvoiceItem.php b/app/InvoiceItem.php index c3bc7272..7249fbf9 100644 --- a/app/InvoiceItem.php +++ b/app/InvoiceItem.php @@ -78,7 +78,8 @@ class InvoiceItem extends Model public function scopeItemAttributes($query) { $query->select( - DB::raw('sum(quantity) as total_quantity, sum(total) as total_amount, item_id') - )->groupBy('item_id'); + DB::raw('sum(quantity) as total_quantity, sum(total) as total_amount, invoice_items.name') + )->groupBy('invoice_items.name'); + } }