From 6e9a420bea92185bddc064f46b570b9b82b50a32 Mon Sep 17 00:00:00 2001 From: paulwer Date: Mon, 30 Jan 2023 10:46:05 +0100 Subject: [PATCH] unify code + fixes --- app/Filters/BankIntegrationFilters.php | 7 ++++--- app/Filters/BankTransactionFilters.php | 9 +++++---- app/Filters/BankTransactionRuleFilters.php | 9 +++++---- app/Filters/ClientFilters.php | 7 ++++--- app/Filters/DesignFilters.php | 2 +- app/Filters/SystemLogFilters.php | 8 ++++---- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app/Filters/BankIntegrationFilters.php b/app/Filters/BankIntegrationFilters.php index 85924f463d..6701f59bf3 100644 --- a/app/Filters/BankIntegrationFilters.php +++ b/app/Filters/BankIntegrationFilters.php @@ -26,10 +26,11 @@ class BankIntegrationFilters extends QueryFilters */ public function name(string $name = ''): Builder { - if(strlen($name) >=1) - return $this->builder->where('bank_account_name', 'like', '%'.$name.'%'); + if (strlen($filter) == 0) { + return $this->builder; + } - return $this->builder; + return $this->builder->where('bank_account_name', 'like', '%'.$name.'%'); } /** diff --git a/app/Filters/BankTransactionFilters.php b/app/Filters/BankTransactionFilters.php index 784d6efc5b..2aabb67f06 100644 --- a/app/Filters/BankTransactionFilters.php +++ b/app/Filters/BankTransactionFilters.php @@ -27,10 +27,11 @@ class BankTransactionFilters extends QueryFilters */ public function name(string $name = ''): Builder { - if(strlen($name) >=1) - return $this->builder->where('bank_account_name', 'like', '%'.$name.'%'); - - return $this->builder; + if (strlen($filter) == 0) { + return $this->builder; + } + + return $this->builder->where('bank_account_name', 'like', '%'.$name.'%'); } /** diff --git a/app/Filters/BankTransactionRuleFilters.php b/app/Filters/BankTransactionRuleFilters.php index c928ca156d..76d3f936d0 100644 --- a/app/Filters/BankTransactionRuleFilters.php +++ b/app/Filters/BankTransactionRuleFilters.php @@ -30,10 +30,11 @@ class BankTransactionRuleFilters extends QueryFilters */ public function name(string $name = ''): Builder { - if(strlen($name) >=1) - return $this->builder->where('name', 'like', '%'.$name.'%'); - - return $this->builder; + if (strlen($filter) == 0) { + return $this->builder; + } + + return $this->builder->where('name', 'like', '%'.$name.'%'); } /** diff --git a/app/Filters/ClientFilters.php b/app/Filters/ClientFilters.php index 2cf72b638e..762e4384aa 100644 --- a/app/Filters/ClientFilters.php +++ b/app/Filters/ClientFilters.php @@ -30,10 +30,11 @@ class ClientFilters extends QueryFilters */ public function name(string $name = ''): Builder { - if(strlen($name) >=1) - return $this->builder->where('name', 'like', '%'.$name.'%'); + if (strlen($filter) == 0) { + return $this->builder; + } - return $this->builder; + return $this->builder->where('name', 'like', '%'.$name.'%'); } /** diff --git a/app/Filters/DesignFilters.php b/app/Filters/DesignFilters.php index 7cd323ef8e..3a2ae7edd6 100644 --- a/app/Filters/DesignFilters.php +++ b/app/Filters/DesignFilters.php @@ -32,7 +32,7 @@ class DesignFilters extends QueryFilters return $this->builder; } - return $this->builder->where(function ($query) use ($filter) { + return $this->builder->where(function ($query) use ($filter) { $query->where('designs.name', 'like', '%'.$filter.'%'); }); } diff --git a/app/Filters/SystemLogFilters.php b/app/Filters/SystemLogFilters.php index 1bef963a1e..8c79691e3e 100644 --- a/app/Filters/SystemLogFilters.php +++ b/app/Filters/SystemLogFilters.php @@ -20,7 +20,7 @@ class SystemLogFilters extends QueryFilters { public function type_id(int $type_id): Builder { - if (isset($event_id) == 0) { + if (isset($event_id)) { return $this->builder; } @@ -29,7 +29,7 @@ class SystemLogFilters extends QueryFilters public function category_id(int $category_id): Builder { - if (isset($event_id) == 0) { + if (isset($event_id)) { return $this->builder; } @@ -38,7 +38,7 @@ class SystemLogFilters extends QueryFilters public function event_id(int $event_id): Builder { - if (isset($event_id) == 0) { + if (isset($event_id)) { return $this->builder; } @@ -54,7 +54,7 @@ class SystemLogFilters extends QueryFilters */ public function filter(string $filter = ''): Builder { - if (strlen($filter) == 0) { + if (strlen($filter)) { return $this->builder; }