From 778a48a6995f94b86f1f4c7c3ffdb645c6751ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 6 Sep 2021 17:34:27 +0200 Subject: [PATCH] Invoices --- app/Http/Livewire/DocumentsTable.php | 13 +++++++++++++ .../components/livewire/documents-table.blade.php | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/app/Http/Livewire/DocumentsTable.php b/app/Http/Livewire/DocumentsTable.php index 058555e99702..0f6f6183675f 100644 --- a/app/Http/Livewire/DocumentsTable.php +++ b/app/Http/Livewire/DocumentsTable.php @@ -17,6 +17,7 @@ use App\Models\Client; use App\Models\Credit; use App\Models\Document; use App\Models\Expense; +use App\Models\Invoice; use App\Utils\Traits\WithSorting; use Livewire\Component; use Livewire\WithPagination; @@ -68,6 +69,10 @@ class DocumentsTable extends Component $this->query = $this->expenses(); break; + case 'invoices': + $this->query = $this->invoices(); + break; + default: $this->query = $this->documents(); break; @@ -94,4 +99,12 @@ class DocumentsTable extends Component $query->where('client_id', $this->client->id); }); } + + protected function invoices() + { + return Document::query() + ->whereHasMorph('documentable', [Invoice::class], function ($query) { + $query->where('client_id', $this->client->id); + }); + } } diff --git a/resources/views/portal/ninja2020/components/livewire/documents-table.blade.php b/resources/views/portal/ninja2020/components/livewire/documents-table.blade.php index 21e52f3f4bb3..49d9da108336 100644 --- a/resources/views/portal/ninja2020/components/livewire/documents-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/documents-table.blade.php @@ -17,6 +17,12 @@ wire:click="updateResources('expenses')" /> {{ ctrans('texts.expenses') }} + +