Fixes for filtering

This commit is contained in:
David Bomba 2023-06-27 22:25:24 +10:00
parent b230836056
commit 9e7f269a0e
2 changed files with 11 additions and 3 deletions

View File

@ -114,8 +114,16 @@ class ExpenseFilters extends QueryFilters
*/ */
public function has_invoices(string $value = ''): Builder public function has_invoices(string $value = ''): Builder
{ {
if ($value == 'true') { $split = explode(",", $value);
return $this->builder->whereNotNull('invoice_id');
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; return $this->builder;

View File

@ -7,7 +7,7 @@ parameters:
- '#Call to an undefined method .*badMethod\(\)#' - '#Call to an undefined method .*badMethod\(\)#'
- '#Call to an undefined method Illuminate\Database\Eloquent\Builder::exclude#' - '#Call to an undefined method Illuminate\Database\Eloquent\Builder::exclude#'
parallel: parallel:
maximumNumberOfProcesses: 8 maximumNumberOfProcesses: 1
level: 4 level: 4
paths: paths:
- 'app/' - 'app/'