From 426d1c45fd037aa2c6b7b3f89b054d6b4c60658a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 17 Dec 2022 10:04:00 +1100 Subject: [PATCH] Filter by private notes --- app/Filters/InvoiceFilters.php | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index d2c5c82aef..410da19872 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -16,6 +16,8 @@ use App\Models\User; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Carbon; +use InvalidArgumentException; +use RuntimeException; /** * InvoiceFilters. @@ -136,6 +138,10 @@ class InvoiceFilters extends QueryFilters }); } + /** + * @return Builder + * @throws RuntimeException + */ public function without_deleted_clients() { @@ -144,6 +150,10 @@ class InvoiceFilters extends QueryFilters }); } + /** + * @return Builder + * @throws InvalidArgumentException + */ public function upcoming() { return $this->builder @@ -154,6 +164,10 @@ class InvoiceFilters extends QueryFilters ->orderBy('due_date', 'ASC'); } + /** + * @return void + * @throws InvalidArgumentException + */ public function overdue() { $this->builder->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) @@ -165,6 +179,11 @@ class InvoiceFilters extends QueryFilters ->orderBy('due_date', 'ASC'); } + /** + * @param string $client_id + * @return Builder + * @throws InvalidArgumentException + */ public function payable(string $client_id = '') { if (strlen($client_id) == 0) { @@ -222,8 +241,20 @@ class InvoiceFilters extends QueryFilters } else { 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.'%'); } /**