From c9fefcd8f4f5c70ce161ed22b66250091de141a6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 28 Oct 2023 18:08:43 +0200 Subject: [PATCH] Add missing method. --- .../UserGroups/Currency/CurrencyRepository.php | 8 ++++++++ .../UserGroups/Currency/CurrencyRepositoryInterface.php | 7 +++++++ app/Support/Search/OperatorQuerySearch.php | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepository.php b/app/Repositories/UserGroups/Currency/CurrencyRepository.php index 99c8763d6a..a421b9c760 100644 --- a/app/Repositories/UserGroups/Currency/CurrencyRepository.php +++ b/app/Repositories/UserGroups/Currency/CurrencyRepository.php @@ -239,6 +239,14 @@ class CurrencyRepository implements CurrencyRepositoryInterface $currency->save(); } + /** + * @inheritDoc + */ + public function findByName(string $name): ?TransactionCurrency + { + return TransactionCurrency::where('name', $name)->first(); + } + /** * Find by object, ID or code. Returns user default or system default. * diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php b/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php index d81a11752c..1ba5fe9667 100644 --- a/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php +++ b/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php @@ -84,6 +84,13 @@ interface CurrencyRepositoryInterface */ public function findByCode(string $currencyCode): ?TransactionCurrency; + /** + * @param string $name + * + * @return TransactionCurrency|null + */ + public function findByName(string $name): ?TransactionCurrency; + /** * Find by object, ID or code. Returns user default or system default. * diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php index ff1ff1c568..470067caea 100644 --- a/app/Support/Search/OperatorQuerySearch.php +++ b/app/Support/Search/OperatorQuerySearch.php @@ -1536,9 +1536,9 @@ class OperatorQuerySearch implements SearchInterface $parts = explode(' ', $value); $value = trim($parts[count($parts) - 1], "() \t\n\r\0\x0B"); } - $result = $this->currencyRepository->findByCodeNull($value); + $result = $this->currencyRepository->findByCode($value); if (null === $result) { - $result = $this->currencyRepository->findByNameNull($value); + $result = $this->currencyRepository->findByName($value); } return $result;