From 3a85441c497074825f56600efeb088692e681b10 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 23 Dec 2022 11:39:41 +1100 Subject: [PATCH] Refactor for livewire --- app/Http/Livewire/InvoicesTable.php | 15 +++++++++++---- .../portal/ninja2020/invoices/index.blade.php | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/Http/Livewire/InvoicesTable.php b/app/Http/Livewire/InvoicesTable.php index f35715e178..3bfaa9390a 100644 --- a/app/Http/Livewire/InvoicesTable.php +++ b/app/Http/Livewire/InvoicesTable.php @@ -13,6 +13,7 @@ namespace App\Http\Livewire; use App\Libraries\MultiDB; +use App\Models\Company; use App\Models\Invoice; use App\Utils\Traits\WithSorting; use Carbon\Carbon; @@ -23,15 +24,21 @@ class InvoicesTable extends Component { use WithPagination, WithSorting; - public $per_page = 10; + public int $per_page = 10; - public $status = []; + public array $status = []; - public $company; + public Company $company; + + public int $company_id; + + public string $db; public function mount() { - MultiDB::setDb($this->company->db); + MultiDB::setDb($this->db); + + $this->company = Company::find($this->company_id); $this->sort_asc = false; diff --git a/resources/views/portal/ninja2020/invoices/index.blade.php b/resources/views/portal/ninja2020/invoices/index.blade.php index 3d23cb6bc3..0ce6e4292b 100644 --- a/resources/views/portal/ninja2020/invoices/index.blade.php +++ b/resources/views/portal/ninja2020/invoices/index.blade.php @@ -23,6 +23,6 @@
- @livewire('invoices-table', ['company' => $company]) + @livewire('invoices-table', ['company_id' => $company->id, 'db' => $company->db])
@endsection