mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactor for livewire
This commit is contained in:
parent
3a85441c49
commit
843229d9b5
@ -3,7 +3,9 @@
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientGatewayToken;
|
||||
use App\Models\Company;
|
||||
use App\Utils\Traits\WithSorting;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
@ -13,17 +15,23 @@ class PaymentMethodsTable extends Component
|
||||
use WithPagination;
|
||||
use WithSorting;
|
||||
|
||||
public $per_page = 10;
|
||||
public int $per_page = 10;
|
||||
|
||||
public $client;
|
||||
public Client $client;
|
||||
|
||||
public $company;
|
||||
public Company $company;
|
||||
|
||||
public function mount($client)
|
||||
public int $client_id;
|
||||
|
||||
public string $db;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
MultiDB::setDb($this->company->db);
|
||||
MultiDB::setDb($this->db);
|
||||
|
||||
$this->client = $client;
|
||||
$this->client = Client::with('company')->find($this->client_id);
|
||||
|
||||
$this->company = $this->client->company;
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
@ -13,6 +13,7 @@
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Company;
|
||||
use App\Models\Payment;
|
||||
use App\Utils\Traits\WithSorting;
|
||||
use Livewire\Component;
|
||||
@ -23,17 +24,19 @@ class PaymentsTable extends Component
|
||||
use WithSorting;
|
||||
use WithPagination;
|
||||
|
||||
public $per_page = 10;
|
||||
public int $per_page = 10;
|
||||
|
||||
public $user;
|
||||
public Company $company;
|
||||
|
||||
public $company;
|
||||
public int $company_id;
|
||||
|
||||
public string $db;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
MultiDB::setDb($this->company->db);
|
||||
MultiDB::setDb($this->db);
|
||||
|
||||
$this->user = auth()->user();
|
||||
$this->company = Company::find($this->company_id);
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
@ -13,6 +13,7 @@
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Company;
|
||||
use App\Models\Quote;
|
||||
use App\Utils\Traits\WithSorting;
|
||||
use Livewire\Component;
|
||||
@ -22,15 +23,27 @@ class QuotesTable extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $per_page = 10;
|
||||
public int $per_page = 10;
|
||||
|
||||
public $status = [];
|
||||
public array $status = [];
|
||||
|
||||
public $company;
|
||||
public Company $company;
|
||||
|
||||
public $sort = 'status_id'; // Default sortBy. Feel free to change or pull from client/company settings.
|
||||
public string $sort = 'status_id';
|
||||
|
||||
public bool $sort_asc = true;
|
||||
|
||||
public int $company_id;
|
||||
|
||||
public string $db;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
MultiDB::setDb($this->db);
|
||||
|
||||
$this->company = Company::find($this->company_id);
|
||||
}
|
||||
|
||||
public $sort_asc = true;
|
||||
|
||||
public function sortBy($field)
|
||||
{
|
||||
@ -41,16 +54,11 @@ class QuotesTable extends Component
|
||||
$this->sort = $field;
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
MultiDB::setDb($this->company->db);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
||||
$query = Quote::query()
|
||||
->with('client.gateway_tokens', 'company', 'client.contacts')
|
||||
->with('client.contacts', 'company')
|
||||
->orderBy($this->sort, $this->sort_asc ? 'asc' : 'desc');
|
||||
|
||||
if (count($this->status) > 0) {
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
@section('body')
|
||||
<div class="flex flex-col">
|
||||
@livewire('payment-methods-table', ['client' => $client, 'company' => $company])
|
||||
@livewire('payment-methods-table', ['client_id' => $client->id, 'db' => $company->db])
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
@section('body')
|
||||
<div class="flex flex-col">
|
||||
@livewire('payments-table', ['company' => $company])
|
||||
@livewire('payments-table', ['company_id' => $company->id, 'db' => $company->db])
|
||||
</div>
|
||||
@endsection
|
@ -26,6 +26,6 @@
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col mt-4">
|
||||
@livewire('quotes-table', ['company' => $company])
|
||||
@livewire('quotes-table', ['company_id' => $company->id, 'db' => $company->db])
|
||||
</div>
|
||||
@endsection
|
||||
|
Loading…
x
Reference in New Issue
Block a user