1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Filter by private notes

This commit is contained in:
David Bomba 2022-12-17 10:04:00 +11:00
parent 4761f8a1c9
commit 426d1c45fd

View File

@ -16,6 +16,8 @@ use App\Models\User;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use InvalidArgumentException;
use RuntimeException;
/** /**
* InvoiceFilters. * InvoiceFilters.
@ -136,6 +138,10 @@ class InvoiceFilters extends QueryFilters
}); });
} }
/**
* @return Builder
* @throws RuntimeException
*/
public function without_deleted_clients() public function without_deleted_clients()
{ {
@ -144,6 +150,10 @@ class InvoiceFilters extends QueryFilters
}); });
} }
/**
* @return Builder
* @throws InvalidArgumentException
*/
public function upcoming() public function upcoming()
{ {
return $this->builder return $this->builder
@ -154,6 +164,10 @@ class InvoiceFilters extends QueryFilters
->orderBy('due_date', 'ASC'); ->orderBy('due_date', 'ASC');
} }
/**
* @return void
* @throws InvalidArgumentException
*/
public function overdue() public function overdue()
{ {
$this->builder->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) $this->builder->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
@ -165,6 +179,11 @@ class InvoiceFilters extends QueryFilters
->orderBy('due_date', 'ASC'); ->orderBy('due_date', 'ASC');
} }
/**
* @param string $client_id
* @return Builder
* @throws InvalidArgumentException
*/
public function payable(string $client_id = '') public function payable(string $client_id = '')
{ {
if (strlen($client_id) == 0) { if (strlen($client_id) == 0) {
@ -222,8 +241,20 @@ class InvoiceFilters extends QueryFilters
} else { } else {
return $this->builder->company()->with(['invitations.company'], ['documents.company']); return $this->builder->company()->with(['invitations.company'], ['documents.company']);
} }
}
// return $this->builder->whereCompanyId(auth()->user()->company()->id); /**
* @param string $filter
* @return Builder
* @throws InvalidArgumentException
*/
public function private_notes($filter = '') :Builder
{
if (strlen($filter) == 0) {
return $this->builder;
}
return $this->builder->where('private_notes', 'LIKE', '%'.$filter.'%');
} }
/** /**