invoiceninja/app/Http/Livewire/PaymentsTable.php

58 lines
1.5 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-29 09:21:40 +11:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
2021-06-16 16:58:16 +10:00
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Http\Livewire;
use App\Libraries\MultiDB;
2022-12-23 11:51:29 +11:00
use App\Models\Company;
use App\Models\Payment;
use App\Utils\Traits\WithSorting;
use Livewire\Component;
use Livewire\WithPagination;
class PaymentsTable extends Component
{
use WithSorting;
use WithPagination;
2022-12-23 11:51:29 +11:00
public int $per_page = 10;
2022-12-23 11:51:29 +11:00
public Company $company;
2022-12-23 11:51:29 +11:00
public int $company_id;
public string $db;
public function mount()
{
2022-12-23 11:51:29 +11:00
MultiDB::setDb($this->db);
2022-12-23 11:51:29 +11:00
$this->company = Company::find($this->company_id);
}
public function render()
{
$query = Payment::query()
->with('type', 'client', 'invoices')
2021-07-04 07:46:25 +10:00
->where('company_id', $this->company->id)
2022-09-16 14:20:46 +10:00
->where('client_id', auth()->guard('contact')->user()->client_id)
->whereIn('status_id', [Payment::STATUS_FAILED, Payment::STATUS_COMPLETED, Payment::STATUS_PENDING, Payment::STATUS_REFUNDED, Payment::STATUS_PARTIALLY_REFUNDED])
->orderBy($this->sort_field, $this->sort_asc ? 'desc' : 'asc')
2021-09-06 18:14:00 +02:00
->withTrashed()
->paginate($this->per_page);
return render('components.livewire.payments-table', [
'payments' => $query,
]);
}
}