From 2b5ceeee9446061f291a8bb1e615a5f9a5030bd3 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 2 Jul 2021 18:28:56 +0800 Subject: [PATCH] add column for old or new customers in the customer excel export --- app/Classes/Modules/Exports/Services/ExportsCustomers.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsCustomers.php b/app/Classes/Modules/Exports/Services/ExportsCustomers.php index 64508087..7e44e619 100644 --- a/app/Classes/Modules/Exports/Services/ExportsCustomers.php +++ b/app/Classes/Modules/Exports/Services/ExportsCustomers.php @@ -43,6 +43,9 @@ class ExportsCustomers implements FromQuery, WithHeadingRow, WithMapping */ public function map($company): array { + dd(count($company->whereHas('segments', function($query){ + return $query->where('id', '=', 5); + })->get()) ? 'Exchange 1.0' : 'Exchange 2.0'); return [ $company->reference, $company->name, @@ -51,7 +54,7 @@ class ExportsCustomers implements FromQuery, WithHeadingRow, WithMapping $company->bookings()->sum('fix_amount'), \PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel($company->created_at), count($company->whereHas('segments', function($query){ - $query->where('id', '=', 5); + return $query->where('id', '=', 5); })->get()) ? 'Exchange 1.0' : 'Exchange 2.0' ]; }