From 7ad1c08d51da2be3f1fa552e8b7fb2a81d73596a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 15 Mar 2023 09:40:31 +1100 Subject: [PATCH] Add search by client from invoices --- app/Filters/InvoiceFilters.php | 5 ++++- app/Repositories/Migration/PaymentMigrationRepository.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 57b778eee3c5..81f3e6db68dd 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -108,7 +108,10 @@ class InvoiceFilters extends QueryFilters ->orWhere('custom_value1', 'like', '%'.$filter.'%') ->orWhere('custom_value2', 'like', '%'.$filter.'%') ->orWhere('custom_value3', 'like', '%'.$filter.'%') - ->orWhere('custom_value4', 'like', '%'.$filter.'%'); + ->orWhere('custom_value4', 'like', '%'.$filter.'%') + ->orWhereHas('client', function ($q) use ($filter){ + $q->where('name', 'like', '%'.$filter.'%'); + }); }); } diff --git a/app/Repositories/Migration/PaymentMigrationRepository.php b/app/Repositories/Migration/PaymentMigrationRepository.php index 11d40e8f976c..d5a00202522b 100644 --- a/app/Repositories/Migration/PaymentMigrationRepository.php +++ b/app/Repositories/Migration/PaymentMigrationRepository.php @@ -100,7 +100,7 @@ class PaymentMigrationRepository extends BaseRepository $payment->deleted_at = $data['deleted_at'] ?: null; $payment->save(); - if (array_key_exists('currency_id', $data) && $data['currency_id'] == 0) { + if ($payment->currency_id == 0) { $payment->currency_id = $payment->company->settings->currency_id; $payment->save(); }