From 218cf81922a3f878fcd29323846fa4b6bcc77d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 6 Sep 2021 17:35:15 +0200 Subject: [PATCH] Payments --- 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 0f6f6183675f..ff162a0b812b 100644 --- a/app/Http/Livewire/DocumentsTable.php +++ b/app/Http/Livewire/DocumentsTable.php @@ -18,6 +18,7 @@ use App\Models\Credit; use App\Models\Document; use App\Models\Expense; use App\Models\Invoice; +use App\Models\Payment; use App\Utils\Traits\WithSorting; use Livewire\Component; use Livewire\WithPagination; @@ -73,6 +74,10 @@ class DocumentsTable extends Component $this->query = $this->invoices(); break; + case 'payments': + $this->query = $this->payments(); + break; + default: $this->query = $this->documents(); break; @@ -107,4 +112,12 @@ class DocumentsTable extends Component $query->where('client_id', $this->client->id); }); } + + protected function payments() + { + return Document::query() + ->whereHasMorph('documentable', [Payment::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 49d9da108336..750e338df918 100644 --- a/resources/views/portal/ninja2020/components/livewire/documents-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/documents-table.blade.php @@ -23,6 +23,12 @@ wire:click="updateResources('invoices')" /> {{ ctrans('texts.invoices') }} + +