From f2de397459bea61408822a015b6d720e085c4ddb Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 22 Jan 2023 19:24:35 +1100 Subject: [PATCH 1/2] Clean up for filters --- app/Filters/CompanyGatewayFilters.php | 2 +- app/Filters/CreditFilters.php | 1 - app/Filters/InvoiceFilters.php | 50 ++++++++++++------------- app/Filters/PaymentFilters.php | 24 ++++++------ app/Filters/PaymentTermFilters.php | 2 +- app/Filters/ProductFilters.php | 18 ++++----- app/Filters/ProjectFilters.php | 18 ++++----- app/Filters/PurchaseOrderFilters.php | 26 ++++++------- app/Filters/QuoteFilters.php | 22 +++++------ app/Filters/RecurringExpenseFilters.php | 4 +- app/Filters/RecurringInvoiceFilters.php | 8 ++-- app/Filters/RecurringQuoteFilters.php | 14 +++---- app/Filters/TaskFilters.php | 13 +++---- app/Filters/TaskStatusFilters.php | 4 +- app/Filters/TaxRateFilters.php | 4 +- app/Filters/TokenFilters.php | 6 +-- app/Filters/UserFilters.php | 12 +++--- app/Filters/VendorFilters.php | 18 ++++----- 18 files changed, 122 insertions(+), 124 deletions(-) diff --git a/app/Filters/CompanyGatewayFilters.php b/app/Filters/CompanyGatewayFilters.php index 291f43388d..07db27b9e5 100644 --- a/app/Filters/CompanyGatewayFilters.php +++ b/app/Filters/CompanyGatewayFilters.php @@ -33,7 +33,7 @@ class CompanyGatewayFilters extends QueryFilters } return $this->builder->where(function ($query) use ($filter) { - $query->where('company_gateways.label', 'like', '%'.$filter.'%'); + $query->where('label', 'like', '%'.$filter.'%'); }); } diff --git a/app/Filters/CreditFilters.php b/app/Filters/CreditFilters.php index cd51ceabb0..dfcff36b9d 100644 --- a/app/Filters/CreditFilters.php +++ b/app/Filters/CreditFilters.php @@ -42,7 +42,6 @@ class CreditFilters extends QueryFilters return $this->builder; } - $credit_filters = []; if (in_array('draft', $status_parameters)) diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 19eb08c828..04c22e4015 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -38,7 +38,7 @@ class InvoiceFilters extends QueryFilters * @param string client_status The invoice status as seen by the client * @return Builder */ - public function client_status(string $value = '') :Builder + public function client_status(string $value = ''): Builder { if (strlen($value) == 0) { return $this->builder; @@ -77,7 +77,7 @@ class InvoiceFilters extends QueryFilters return $this->builder; } - public function number(string $number = '') :Builder + public function number(string $number = ''): Builder { if(strlen($number) == 0) return $this->builder; @@ -92,22 +92,22 @@ class InvoiceFilters extends QueryFilters * @return Builder * @deprecated */ - public function filter(string $filter = '') : Builder + public function filter(string $filter = ''): Builder { if (strlen($filter) == 0) { return $this->builder; } - return $this->builder->where(function ($query) use ($filter) { - $query->where('invoices.number', 'like', '%'.$filter.'%') - ->orWhere('invoices.po_number', 'like', '%'.$filter.'%') - ->orWhere('invoices.date', 'like', '%'.$filter.'%') - ->orWhere('invoices.amount', 'like', '%'.$filter.'%') - ->orWhere('invoices.balance', 'like', '%'.$filter.'%') - ->orWhere('invoices.custom_value1', 'like', '%'.$filter.'%') - ->orWhere('invoices.custom_value2', 'like', '%'.$filter.'%') - ->orWhere('invoices.custom_value3', 'like', '%'.$filter.'%') - ->orWhere('invoices.custom_value4', 'like', '%'.$filter.'%'); + return $this->builder->where(function ($query) use ($filter) { + $query->where('number', 'like', '%'.$filter.'%') + ->orWhere('po_number', 'like', '%'.$filter.'%') + ->orWhere('date', 'like', '%'.$filter.'%') + ->orWhere('amount', 'like', '%'.$filter.'%') + ->orWhere('balance', 'like', '%'.$filter.'%') + ->orWhere('custom_value1', 'like', '%'.$filter.'%') + ->orWhere('custom_value2', 'like', '%'.$filter.'%') + ->orWhere('custom_value3', 'like', '%'.$filter.'%') + ->orWhere('custom_value4', 'like', '%'.$filter.'%'); }); } @@ -115,7 +115,7 @@ class InvoiceFilters extends QueryFilters * @return Builder * @throws RuntimeException */ - public function without_deleted_clients() + public function without_deleted_clients(): Builder { return $this->builder->whereHas('client', function ($query) { @@ -127,7 +127,7 @@ class InvoiceFilters extends QueryFilters * @return Builder * @throws InvalidArgumentException */ - public function upcoming() + public function upcoming(): Builder { return $this->builder ->where(function ($query) { @@ -141,15 +141,15 @@ class InvoiceFilters extends QueryFilters * @return void * @throws InvalidArgumentException */ - public function overdue() + public function overdue(): Builder { - $this->builder->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) - ->where('is_deleted', 0) - ->where(function ($query) { - $query->where('due_date', '<', now()) - ->orWhere('partial_due_date', '<', now()); - }) - ->orderBy('due_date', 'ASC'); + return $this->builder->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) + ->where('is_deleted', 0) + ->where(function ($query) { + $query->where('due_date', '<', now()) + ->orWhere('partial_due_date', '<', now()); + }) + ->orderBy('due_date', 'ASC'); } /** @@ -157,7 +157,7 @@ class InvoiceFilters extends QueryFilters * @return Builder * @throws InvalidArgumentException */ - public function payable(string $client_id = '') + public function payable(string $client_id = ''): Builder { if (strlen($client_id) == 0) { return $this->builder; @@ -175,7 +175,7 @@ class InvoiceFilters extends QueryFilters * @param string sort formatted as column|asc * @return Builder */ - public function sort(string $sort = '') : Builder + public function sort(string $sort = ''): Builder { $sort_col = explode('|', $sort); diff --git a/app/Filters/PaymentFilters.php b/app/Filters/PaymentFilters.php index 2977e072cb..2d86e6c0b4 100644 --- a/app/Filters/PaymentFilters.php +++ b/app/Filters/PaymentFilters.php @@ -25,26 +25,26 @@ class PaymentFilters extends QueryFilters * @return Builder * @deprecated */ - public function filter(string $filter = '') : Builder + public function filter(string $filter = ''): Builder { if (strlen($filter) == 0) { return $this->builder; } return $this->builder->where(function ($query) use ($filter) { - $query->where('payments.amount', 'like', '%'.$filter.'%') - ->orWhere('payments.date', 'like', '%'.$filter.'%') - ->orWhere('payments.custom_value1', 'like', '%'.$filter.'%') - ->orWhere('payments.custom_value2', 'like', '%'.$filter.'%') - ->orWhere('payments.custom_value3', 'like', '%'.$filter.'%') - ->orWhere('payments.custom_value4', 'like', '%'.$filter.'%'); + $query->where('amount', 'like', '%'.$filter.'%') + ->orWhere('date', 'like', '%'.$filter.'%') + ->orWhere('custom_value1', 'like', '%'.$filter.'%') + ->orWhere('custom_value2', 'like', '%'.$filter.'%') + ->orWhere('custom_value3', 'like', '%'.$filter.'%') + ->orWhere('custom_value4', 'like', '%'.$filter.'%'); }); } /** * Returns a list of payments that can be matched to bank transactions */ - public function match_transactions($value = 'true') :Builder + public function match_transactions($value = 'true'): Builder { if($value == 'true'){ @@ -68,7 +68,7 @@ class PaymentFilters extends QueryFilters * @param string sort formatted as column|asc * @return Builder */ - public function sort(string $sort) : Builder + public function sort(string $sort): Builder { $sort_col = explode('|', $sort); @@ -78,7 +78,7 @@ class PaymentFilters extends QueryFilters return true; } - public function number(string $number) : Builder + public function number(string $number = ''): Builder { return $this->builder->where('number', $number); } @@ -88,7 +88,7 @@ class PaymentFilters extends QueryFilters * * @return Illuminate\Database\Query\Builder */ - public function entityFilter() + public function entityFilter(): Builder { if (auth()->guard('contact')->user()) { return $this->contactViewFilter(); @@ -103,7 +103,7 @@ class PaymentFilters extends QueryFilters * * @return Builder */ - private function contactViewFilter() : Builder + private function contactViewFilter(): Builder { return $this->builder ->whereCompanyId(auth()->guard('contact')->user()->company->id) diff --git a/app/Filters/PaymentTermFilters.php b/app/Filters/PaymentTermFilters.php index fb4be8c424..13d1884b48 100644 --- a/app/Filters/PaymentTermFilters.php +++ b/app/Filters/PaymentTermFilters.php @@ -32,7 +32,7 @@ class PaymentTermFilters extends QueryFilters } return $this->builder->where(function ($query) use ($filter) { - $query->where('payment_terms.name', 'like', '%'.$filter.'%'); + $query->where('name', 'like', '%'.$filter.'%'); }); } diff --git a/app/Filters/ProductFilters.php b/app/Filters/ProductFilters.php index 1d6f524c92..ea8a2b1428 100644 --- a/app/Filters/ProductFilters.php +++ b/app/Filters/ProductFilters.php @@ -27,23 +27,23 @@ class ProductFilters extends QueryFilters * @return Builder * @deprecated */ - public function filter(string $filter = '') : Builder + public function filter(string $filter = ''): Builder { if (strlen($filter) == 0) { return $this->builder; } return $this->builder->where(function ($query) use ($filter) { - $query->where('products.product_key', 'like', '%'.$filter.'%') - ->orWhere('products.notes', 'like', '%'.$filter.'%') - ->orWhere('products.custom_value1', 'like', '%'.$filter.'%') - ->orWhere('products.custom_value2', 'like', '%'.$filter.'%') - ->orWhere('products.custom_value3', 'like', '%'.$filter.'%') - ->orWhere('products.custom_value4', 'like', '%'.$filter.'%'); + $query->where('product_key', 'like', '%'.$filter.'%') + ->orWhere('notes', 'like', '%'.$filter.'%') + ->orWhere('custom_value1', 'like', '%'.$filter.'%') + ->orWhere('custom_value2', 'like', '%'.$filter.'%') + ->orWhere('custom_value3', 'like', '%'.$filter.'%') + ->orWhere('custom_value4', 'like', '%'.$filter.'%'); }); } - public function product_key(string $filter = '') : Builder + public function product_key(string $filter = ''): Builder { if (strlen($filter) == 0) { return $this->builder; @@ -58,7 +58,7 @@ class ProductFilters extends QueryFilters * @param string sort formatted as column|asc * @return Builder */ - public function sort(string $sort) : Builder + public function sort(string $sort): Builder { $sort_col = explode('|', $sort); diff --git a/app/Filters/ProjectFilters.php b/app/Filters/ProjectFilters.php index 030a7be215..197d4c133e 100644 --- a/app/Filters/ProjectFilters.php +++ b/app/Filters/ProjectFilters.php @@ -22,19 +22,19 @@ class ProjectFilters extends QueryFilters * Filter based on search text. * * @param string query filter - * @return Builder + * @return Illuminate\Eloquent\Query\Builder * @deprecated */ - public function filter(string $filter = '') : Builder + public function filter(string $filter = '') :Builder { if (strlen($filter) == 0) { return $this->builder; } return $this->builder->where(function ($query) use ($filter) { - $query->where('projects.name', 'like', '%'.$filter.'%') - ->orWhere('projects.public_notes', 'like', '%'.$filter.'%') - ->orWhere('projects.private_notes', 'like', '%'.$filter.'%'); + $query->where('name', 'like', '%'.$filter.'%') + ->orWhere('public_notes', 'like', '%'.$filter.'%') + ->orWhere('private_notes', 'like', '%'.$filter.'%'); }); } @@ -42,9 +42,9 @@ class ProjectFilters extends QueryFilters * Sorts the list based on $sort. * * @param string sort formatted as column|asc - * @return Builder + * @return Illuminate\Eloquent\Query\Builder */ - public function sort(string $sort) : Builder + public function sort(string $sort) :Builder { $sort_col = explode('|', $sort); @@ -55,9 +55,9 @@ class ProjectFilters extends QueryFilters /** * Filters the query by the users company ID. * - * @return Illuminate\Database\Query\Builder + * @return Illuminate\Eloquent\Query\Builder */ - public function entityFilter() + public function entityFilter() :Builder { return $this->builder->company(); } diff --git a/app/Filters/PurchaseOrderFilters.php b/app/Filters/PurchaseOrderFilters.php index 5c21080da3..53fa294b15 100644 --- a/app/Filters/PurchaseOrderFilters.php +++ b/app/Filters/PurchaseOrderFilters.php @@ -29,7 +29,7 @@ class PurchaseOrderFilters extends QueryFilters * * @return Builder */ - public function client_status(string $value = '') :Builder + public function client_status(string $value = ''): Builder { if (strlen($value) == 0) { return $this->builder; @@ -81,22 +81,22 @@ class PurchaseOrderFilters extends QueryFilters * @return Builder * @deprecated */ - public function filter(string $filter = '') : Builder + public function filter(string $filter = ''): Builder { if (strlen($filter) == 0) { return $this->builder; } return $this->builder->where(function ($query) use ($filter) { - $query->where('purchase_orders.number', 'like', '%'.$filter.'%') - ->orWhere('purchase_orders.number', 'like', '%'.$filter.'%') - ->orWhere('purchase_orders.date', 'like', '%'.$filter.'%') - ->orWhere('purchase_orders.amount', 'like', '%'.$filter.'%') - ->orWhere('purchase_orders.balance', 'like', '%'.$filter.'%') - ->orWhere('purchase_orders.custom_value1', 'like', '%'.$filter.'%') - ->orWhere('purchase_orders.custom_value2', 'like', '%'.$filter.'%') - ->orWhere('purchase_orders.custom_value3', 'like', '%'.$filter.'%') - ->orWhere('purchase_orders.custom_value4', 'like', '%'.$filter.'%'); + $query->where('number', 'like', '%'.$filter.'%') + ->orWhere('number', 'like', '%'.$filter.'%') + ->orWhere('date', 'like', '%'.$filter.'%') + ->orWhere('amount', 'like', '%'.$filter.'%') + ->orWhere('balance', 'like', '%'.$filter.'%') + ->orWhere('custom_value1', 'like', '%'.$filter.'%') + ->orWhere('custom_value2', 'like', '%'.$filter.'%') + ->orWhere('custom_value3', 'like', '%'.$filter.'%') + ->orWhere('custom_value4', 'like', '%'.$filter.'%'); }); } @@ -106,7 +106,7 @@ class PurchaseOrderFilters extends QueryFilters * @param string sort formatted as column|asc * @return Builder */ - public function sort(string $sort) : Builder + public function sort(string $sort): Builder { $sort_col = explode('|', $sort); @@ -119,7 +119,7 @@ class PurchaseOrderFilters extends QueryFilters * We need to ensure we are using the correct company ID * as we could be hitting this from either the client or company auth guard */ - public function entityFilter() + public function entityFilter(): Builder { if (auth()->guard('contact')->user()) { return $this->contactViewFilter(); diff --git a/app/Filters/QuoteFilters.php b/app/Filters/QuoteFilters.php index c0b88a82b4..0be9a8d0b1 100644 --- a/app/Filters/QuoteFilters.php +++ b/app/Filters/QuoteFilters.php @@ -26,18 +26,18 @@ class QuoteFilters extends QueryFilters * @return Builder * @deprecated */ - public function filter(string $filter = '') : Builder + public function filter(string $filter = ''): Builder { if (strlen($filter) == 0) { return $this->builder; } return $this->builder->where(function ($query) use ($filter) { - $query->where('quotes.number', 'like', '%'.$filter.'%') - ->orwhere('quotes.custom_value1', 'like', '%'.$filter.'%') - ->orWhere('quotes.custom_value2', 'like', '%'.$filter.'%') - ->orWhere('quotes.custom_value3', 'like', '%'.$filter.'%') - ->orWhere('quotes.custom_value4', 'like', '%'.$filter.'%'); + $query->where('number', 'like', '%'.$filter.'%') + ->orwhere('custom_value1', 'like', '%'.$filter.'%') + ->orWhere('custom_value2', 'like', '%'.$filter.'%') + ->orWhere('custom_value3', 'like', '%'.$filter.'%') + ->orWhere('custom_value4', 'like', '%'.$filter.'%'); }); } @@ -53,7 +53,7 @@ class QuoteFilters extends QueryFilters * @param string client_status The invoice status as seen by the client * @return Builder */ - public function client_status(string $value = '') :Builder + public function client_status(string $value = ''): Builder { if (strlen($value) == 0) { return $this->builder; @@ -111,7 +111,7 @@ class QuoteFilters extends QueryFilters return $this->builder; } - public function number($number = '') + public function number($number = ''): Builder { return $this->builder->where('number', 'like', '%'.$number.'%'); } @@ -122,7 +122,7 @@ class QuoteFilters extends QueryFilters * @param string sort formatted as column|asc * @return Builder */ - public function sort(string $sort) : Builder + public function sort(string $sort): Builder { $sort_col = explode('|', $sort); @@ -135,9 +135,9 @@ class QuoteFilters extends QueryFilters /** * Filters the query by the users company ID. * - * @return Illuminate\Database\Query\Builder + * @return Illuminate\Eloquent\Query\Builder */ - public function entityFilter() + public function entityFilter(): Builder { return $this->builder->company(); } diff --git a/app/Filters/RecurringExpenseFilters.php b/app/Filters/RecurringExpenseFilters.php index f7a0872720..66c9ce83f5 100644 --- a/app/Filters/RecurringExpenseFilters.php +++ b/app/Filters/RecurringExpenseFilters.php @@ -56,9 +56,9 @@ class RecurringExpenseFilters extends QueryFilters /** * Filters the query by the users company ID. * - * @return Illuminate\Database\Query\Builder + * @return Illuminate\Eloquent\Builder */ - public function entityFilter() + public function entityFilter(): Builder { return $this->builder->company(); } diff --git a/app/Filters/RecurringInvoiceFilters.php b/app/Filters/RecurringInvoiceFilters.php index 88a0f4ee3c..a538c8c974 100644 --- a/app/Filters/RecurringInvoiceFilters.php +++ b/app/Filters/RecurringInvoiceFilters.php @@ -26,7 +26,7 @@ class RecurringInvoiceFilters extends QueryFilters * @return Builder * @deprecated */ - public function filter(string $filter = '') : Builder + public function filter(string $filter = ''): Builder { if (strlen($filter) == 0) { return $this->builder; @@ -52,7 +52,7 @@ class RecurringInvoiceFilters extends QueryFilters * @param string client_status The invoice status as seen by the client * @return Builder */ - public function client_status(string $value = '') :Builder + public function client_status(string $value = ''): Builder { if (strlen($value) == 0) { return $this->builder; @@ -89,7 +89,7 @@ class RecurringInvoiceFilters extends QueryFilters * @param string sort formatted as column|asc * @return Builder */ - public function sort(string $sort) : Builder + public function sort(string $sort): Builder { $sort_col = explode('|', $sort); @@ -99,7 +99,7 @@ class RecurringInvoiceFilters extends QueryFilters /** * Filters the query by the users company ID. * - * @return Illuminate\Database\Query\Builder + * @return Illuminate\Eloquent\Builder */ public function entityFilter() { diff --git a/app/Filters/RecurringQuoteFilters.php b/app/Filters/RecurringQuoteFilters.php index 1229ee4c5a..90546d725b 100644 --- a/app/Filters/RecurringQuoteFilters.php +++ b/app/Filters/RecurringQuoteFilters.php @@ -22,7 +22,7 @@ class RecurringQuoteFilters extends QueryFilters * Filter based on search text. * * @param string query filter - * @return Builder + * @return Illuminate\Database\Eloquent\Builder * @deprecated */ public function filter(string $filter = ''): Builder @@ -32,10 +32,10 @@ class RecurringQuoteFilters extends QueryFilters } return $this->builder->where(function ($query) use ($filter) { - $query->where('recurring_quotes.custom_value1', 'like', '%'.$filter.'%') - ->orWhere('recurring_quotes.custom_value2', 'like', '%'.$filter.'%') - ->orWhere('recurring_quotes.custom_value3', 'like', '%'.$filter.'%') - ->orWhere('recurring_quotes.custom_value4', 'like', '%'.$filter.'%'); + $query->where('custom_value1', 'like', '%'.$filter.'%') + ->orWhere('custom_value2', 'like', '%'.$filter.'%') + ->orWhere('custom_value3', 'like', '%'.$filter.'%') + ->orWhere('custom_value4', 'like', '%'.$filter.'%'); }); } @@ -43,7 +43,7 @@ class RecurringQuoteFilters extends QueryFilters * Sorts the list based on $sort. * * @param string sort formatted as column|asc - * @return Builder + * @return Illuminate\Database\Eloquent\Builder */ public function sort(string $sort): Builder { @@ -55,7 +55,7 @@ class RecurringQuoteFilters extends QueryFilters /** * Filters the query by the users company ID. * - * @return Builder + * @return Illuminate\Database\Eloquent\Builder */ public function entityFilter(): Builder { diff --git a/app/Filters/TaskFilters.php b/app/Filters/TaskFilters.php index 43e77faff1..591265b34b 100644 --- a/app/Filters/TaskFilters.php +++ b/app/Filters/TaskFilters.php @@ -35,15 +35,14 @@ class TaskFilters extends QueryFilters } return $this->builder->where(function ($query) use ($filter) { - $query->where('tasks.description', 'like', '%'.$filter.'%') - ->orWhere('tasks.custom_value1', 'like', '%'.$filter.'%') - ->orWhere('tasks.custom_value2', 'like', '%'.$filter.'%') - ->orWhere('tasks.custom_value3', 'like', '%'.$filter.'%') - ->orWhere('tasks.custom_value4', 'like', '%'.$filter.'%'); + $query->where('description', 'like', '%'.$filter.'%') + ->orWhere('custom_value1', 'like', '%'.$filter.'%') + ->orWhere('custom_value2', 'like', '%'.$filter.'%') + ->orWhere('custom_value3', 'like', '%'.$filter.'%') + ->orWhere('custom_value4', 'like', '%'.$filter.'%'); }); } - /** * Filter based on client status. * @@ -73,7 +72,7 @@ class TaskFilters extends QueryFilters return $this->builder; } - public function project_tasks($project) + public function project_tasks($project): Builder { if (strlen($project) == 0) { diff --git a/app/Filters/TaskStatusFilters.php b/app/Filters/TaskStatusFilters.php index 61ecf95b7b..26a9d09db2 100644 --- a/app/Filters/TaskStatusFilters.php +++ b/app/Filters/TaskStatusFilters.php @@ -32,7 +32,7 @@ class TaskStatusFilters extends QueryFilters } return $this->builder->where(function ($query) use ($filter) { - $query->where('task_statuses.name', 'like', '%'.$filter.'%'); + $query->where('name', 'like', '%'.$filter.'%'); }); } @@ -42,7 +42,7 @@ class TaskStatusFilters extends QueryFilters * @param string sort formatted as column|asc * @return Builder */ - public function sort(string $sort) : Builder + public function sort(string $sort): Builder { $sort_col = explode('|', $sort); diff --git a/app/Filters/TaxRateFilters.php b/app/Filters/TaxRateFilters.php index 1e838b779a..4b557eef99 100644 --- a/app/Filters/TaxRateFilters.php +++ b/app/Filters/TaxRateFilters.php @@ -32,7 +32,7 @@ class TaxRateFilters extends QueryFilters } return $this->builder->where(function ($query) use ($filter) { - $query->where('tax_rates.name', 'like', '%'.$filter.'%'); + $query->where('name', 'like', '%'.$filter.'%'); }); } @@ -42,7 +42,7 @@ class TaxRateFilters extends QueryFilters * @param string sort formatted as column|asc * @return Builder */ - public function sort(string $sort) : Builder + public function sort(string $sort): Builder { $sort_col = explode('|', $sort); diff --git a/app/Filters/TokenFilters.php b/app/Filters/TokenFilters.php index d4cd948bcb..53ed0bbac5 100644 --- a/app/Filters/TokenFilters.php +++ b/app/Filters/TokenFilters.php @@ -25,14 +25,14 @@ class TokenFilters extends QueryFilters * @return Builder * @deprecated */ - public function filter(string $filter = '') : Builder + public function filter(string $filter = ''): Builder { if (strlen($filter) == 0) { return $this->builder; } return $this->builder->where(function ($query) use ($filter) { - $query->where('company_tokens.name', 'like', '%'.$filter.'%'); + $query->where('name', 'like', '%'.$filter.'%'); }); } @@ -42,7 +42,7 @@ class TokenFilters extends QueryFilters * @param string sort formatted as column|asc * @return Builder */ - public function sort(string $sort) : Builder + public function sort(string $sort): Builder { $sort_col = explode('|', $sort); diff --git a/app/Filters/UserFilters.php b/app/Filters/UserFilters.php index 9867489552..e60f8fb65c 100644 --- a/app/Filters/UserFilters.php +++ b/app/Filters/UserFilters.php @@ -25,17 +25,17 @@ class UserFilters extends QueryFilters * @return Builder * @deprecated */ - public function filter(string $filter = '') : Builder + public function filter(string $filter = ''): Builder { if (strlen($filter) == 0) { return $this->builder; } return $this->builder->where(function ($query) use ($filter) { - $query->where('users.first_name', 'like', '%'.$filter.'%') - ->orWhere('users.last_name', 'like', '%'.$filter.'%') - ->orWhere('users.email', 'like', '%'.$filter.'%') - ->orWhere('users.signature', 'like', '%'.$filter.'%'); + $query->where('first_name', 'like', '%'.$filter.'%') + ->orWhere('last_name', 'like', '%'.$filter.'%') + ->orWhere('email', 'like', '%'.$filter.'%') + ->orWhere('signature', 'like', '%'.$filter.'%'); }); } @@ -46,7 +46,7 @@ class UserFilters extends QueryFilters * @param string sort formatted as column|asc * @return Builder */ - public function sort(string $sort) : Builder + public function sort(string $sort): Builder { $sort_col = explode('|', $sort); diff --git a/app/Filters/VendorFilters.php b/app/Filters/VendorFilters.php index f723893cef..cbc9fa0e77 100644 --- a/app/Filters/VendorFilters.php +++ b/app/Filters/VendorFilters.php @@ -32,17 +32,17 @@ class VendorFilters extends QueryFilters } return $this->builder->where(function ($query) use ($filter) { - $query->where('vendors.name', 'like', '%'.$filter.'%') - ->orWhere('vendors.id_number', 'like', '%'.$filter.'%') + $query->where('name', 'like', '%'.$filter.'%') + ->orWhere('id_number', 'like', '%'.$filter.'%') ->orWhereHas('contacts', function ($query) use ($filter) { - $query->where('vendor_contacts.first_name', 'like', '%'.$filter.'%'); - $query->orWhere('vendor_contacts.last_name', 'like', '%'.$filter.'%'); - $query->orWhere('vendor_contacts.email', 'like', '%'.$filter.'%'); + $query->where('first_name', 'like', '%'.$filter.'%'); + $query->orWhere('last_name', 'like', '%'.$filter.'%'); + $query->orWhere('email', 'like', '%'.$filter.'%'); }) - ->orWhere('vendors.custom_value1', 'like', '%'.$filter.'%') - ->orWhere('vendors.custom_value2', 'like', '%'.$filter.'%') - ->orWhere('vendors.custom_value3', 'like', '%'.$filter.'%') - ->orWhere('vendors.custom_value4', 'like', '%'.$filter.'%'); + ->orWhere('custom_value1', 'like', '%'.$filter.'%') + ->orWhere('custom_value2', 'like', '%'.$filter.'%') + ->orWhere('custom_value3', 'like', '%'.$filter.'%') + ->orWhere('custom_value4', 'like', '%'.$filter.'%'); }); } From ff97330d54ed48a4780de599a37f4210a4d9f445 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 22 Jan 2023 21:01:04 +1100 Subject: [PATCH 2/2] Fixes for client observer --- VERSION.txt | 2 +- app/Observers/ClientContactObserver.php | 4 ++-- config/ninja.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index e17a8ff63c..e92da973fe 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.5.59 \ No newline at end of file +5.5.60 \ No newline at end of file diff --git a/app/Observers/ClientContactObserver.php b/app/Observers/ClientContactObserver.php index 54c49fff1d..49881f0537 100644 --- a/app/Observers/ClientContactObserver.php +++ b/app/Observers/ClientContactObserver.php @@ -67,7 +67,7 @@ class ClientContactObserver QuoteInvitation::withTrashed()->where('client_contact_id', $client_contact_id)->cursor()->each(function ($invite){ - if($invite->invoice()->doesnthave('invitations')) + if($invite->quote()->doesnthave('invitations')) $invite->quote->service()->createInvitations(); }); @@ -75,7 +75,7 @@ class ClientContactObserver RecurringInvoiceInvitation::withTrashed()->where('client_contact_id', $client_contact_id)->cursor()->each(function ($invite){ if($invite->recurring_invoice()->doesnthave('invitations')) - $invite->quote->service()->createInvitations(); + $invite->recurring_invoice->service()->createInvitations(); }); diff --git a/config/ninja.php b/config/ninja.php index cd0e594e5c..ea66940ea2 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.5.59', - 'app_tag' => '5.5.59', + 'app_version' => '5.5.60', + 'app_tag' => '5.5.60', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),