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