diff --git a/app/Filters/ExpenseFilters.php b/app/Filters/ExpenseFilters.php index 847964af994e..922db6c8fd0b 100644 --- a/app/Filters/ExpenseFilters.php +++ b/app/Filters/ExpenseFilters.php @@ -114,8 +114,16 @@ class ExpenseFilters extends QueryFilters */ public function has_invoices(string $value = ''): Builder { - if ($value == 'true') { - return $this->builder->whereNotNull('invoice_id'); + $split = explode(",", $value); + + if (is_array($split) && in_array($split[0], ['client', 'project'])) { + + $search_key = $split[0] == 'client' ? 'client_id' : 'project_id'; + + return $this->builder->whereNotNull('invoice_id') + ->whereHas('invoice', function ($query) use ($search_key, $split){ + $query->where($search_key, $this->decodePrimaryKey($split[1])); + }); } return $this->builder; diff --git a/phpstan.neon b/phpstan.neon index 8bbf3a89f08a..4fcf09b7dab7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,7 +7,7 @@ parameters: - '#Call to an undefined method .*badMethod\(\)#' - '#Call to an undefined method Illuminate\Database\Eloquent\Builder::exclude#' parallel: - maximumNumberOfProcesses: 8 + maximumNumberOfProcesses: 1 level: 4 paths: - 'app/'