2020-04-23 00:49:23 +02:00
|
|
|
<?php
|
|
|
|
|
2020-12-05 14:24:21 +01:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-12-05 14:24:21 +01:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-12-05 14:24:21 +01:00
|
|
|
*/
|
|
|
|
|
2023-12-13 17:52:49 +01:00
|
|
|
namespace App\Livewire;
|
2020-04-23 00:49:23 +02:00
|
|
|
|
2021-07-03 23:46:25 +02:00
|
|
|
use App\Libraries\MultiDB;
|
2020-04-23 00:49:23 +02:00
|
|
|
use App\Models\RecurringInvoice;
|
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 RecurringInvoicesTable extends Component
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
use WithPagination;
|
|
|
|
use WithSorting;
|
2020-04-23 00:49:23 +02:00
|
|
|
|
|
|
|
public $per_page = 10;
|
|
|
|
|
2021-07-03 23:46:25 +02:00
|
|
|
public $company;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2021-04-19 16:57:25 +02:00
|
|
|
public function mount()
|
|
|
|
{
|
2021-07-03 23:46:25 +02:00
|
|
|
MultiDB::setDb($this->company->db);
|
|
|
|
|
2021-04-19 16:57:25 +02:00
|
|
|
$this->sort_asc = false;
|
|
|
|
|
|
|
|
$this->sort_field = 'date';
|
|
|
|
}
|
|
|
|
|
2020-04-23 00:49:23 +02:00
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
$query = RecurringInvoice::query();
|
|
|
|
|
|
|
|
$query = $query
|
2022-09-16 06:20:46 +02:00
|
|
|
->where('client_id', auth()->guard('contact')->user()->client_id)
|
2021-07-03 23:46:25 +02:00
|
|
|
->where('company_id', $this->company->id)
|
2021-11-10 05:16:56 +01:00
|
|
|
->whereIn('status_id', [RecurringInvoice::STATUS_ACTIVE])
|
2020-04-23 00:49:23 +02:00
|
|
|
->orderBy('status_id', 'asc')
|
|
|
|
->with('client')
|
|
|
|
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc')
|
2021-09-10 21:47:28 +02:00
|
|
|
->withTrashed()
|
2021-09-27 18:46:52 +02:00
|
|
|
->where('is_deleted', false)
|
2020-04-23 00:49:23 +02:00
|
|
|
->paginate($this->per_page);
|
|
|
|
|
|
|
|
return render('components.livewire.recurring-invoices-table', [
|
2020-09-06 11:38:10 +02:00
|
|
|
'invoices' => $query,
|
2020-04-23 00:49:23 +02:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|