1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 07:33:04 +01:00
invoiceninja/app/Livewire/PaymentMethodsTable.php

55 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2023-12-13 17:52:49 +01:00
namespace App\Livewire;
use App\Libraries\MultiDB;
2022-12-23 01:51:29 +01:00
use App\Models\Client;
use App\Models\ClientGatewayToken;
2022-12-23 01:51:29 +01:00
use App\Models\Company;
use App\Utils\Traits\WithSorting;
use Livewire\Component;
use Livewire\WithPagination;
class PaymentMethodsTable extends Component
{
use WithPagination;
use WithSorting;
2023-02-28 21:59:14 +01:00
public $per_page = 10;
2022-12-23 01:51:29 +01:00
public Client $client;
2022-12-23 01:51:29 +01:00
public Company $company;
2022-12-23 01:51:29 +01:00
public int $client_id;
public string $db;
public function mount()
{
2022-12-23 01:51:29 +01:00
MultiDB::setDb($this->db);
$this->client = Client::withTrashed()->with('company')->find($this->client_id);
2022-12-23 01:51:29 +01:00
$this->company = $this->client->company;
}
public function render()
{
$query = ClientGatewayToken::query()
->with('gateway_type')
2021-07-03 23:46:25 +02:00
->where('company_id', $this->company->id)
->where('client_id', $this->client->id)
->whereHas('gateway', function ($query) {
$query->where('is_deleted', 0)
->where('deleted_at', null);
})
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc')
->paginate($this->per_page);
return render('components.livewire.payment-methods-table', [
'payment_methods' => $query,
]);
}
}