From 5d54d4313a8bde3511a24693e51e50013a44fd92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 14 May 2020 03:05:18 +0200 Subject: [PATCH] Fix status filters (#3700) --- app/Http/Livewire/InvoicesTable.php | 5 +++-- app/Http/Livewire/QuotesTable.php | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Http/Livewire/InvoicesTable.php b/app/Http/Livewire/InvoicesTable.php index ffab5cb39904..5ed20a85b1d9 100644 --- a/app/Http/Livewire/InvoicesTable.php +++ b/app/Http/Livewire/InvoicesTable.php @@ -31,7 +31,6 @@ class InvoicesTable extends Component public function render() { $query = Invoice::query() - ->where('company_id', auth('contact')->user()->company->id) ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc'); if (in_array('paid', $this->status)) { @@ -48,7 +47,9 @@ class InvoicesTable extends Component ->orWhere('partial_due_date', '<', Carbon::now()); } - $query = $query->paginate($this->per_page); + $query = $query + ->where('company_id', auth('contact')->user()->company->id) + ->paginate($this->per_page); return render('components.livewire.invoices-table', [ 'invoices' => $query, diff --git a/app/Http/Livewire/QuotesTable.php b/app/Http/Livewire/QuotesTable.php index a32a6598263d..d27c59bd7434 100644 --- a/app/Http/Livewire/QuotesTable.php +++ b/app/Http/Livewire/QuotesTable.php @@ -27,9 +27,8 @@ class QuotesTable extends Component public function render() { $query = Quote::query() - ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') - ->where('company_id', auth('contact')->user()->company->id); - + ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc'); + if (in_array('draft', $this->status)) { $query = $query->orWhere('status_id', Quote::STATUS_DRAFT); } @@ -46,7 +45,9 @@ class QuotesTable extends Component $query = $query->orWhere('status_id', Quote::STATUS_EXPIRED); } - $query = $query->paginate($this->per_page); + $query = $query + ->where('company_id', auth('contact')->user()->company->id) + ->paginate($this->per_page); return render('components.livewire.quotes-table', [ 'quotes' => $query