2020-04-23 00:49:23 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
use WithPagination, WithSorting;
|
|
|
|
|
|
|
|
public $per_page = 10;
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
$query = RecurringInvoice::query();
|
|
|
|
|
|
|
|
$query = $query
|
2020-06-10 15:35:39 +02:00
|
|
|
->where('client_id', auth('contact')->user()->client->id)
|
2020-04-23 00:49:23 +02:00
|
|
|
->whereIn('status_id', [RecurringInvoice::STATUS_PENDING, RecurringInvoice::STATUS_ACTIVE, RecurringInvoice::STATUS_COMPLETED])
|
|
|
|
->orderBy('status_id', 'asc')
|
|
|
|
->with('client')
|
|
|
|
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc')
|
|
|
|
->paginate($this->per_page);
|
|
|
|
|
|
|
|
return render('components.livewire.recurring-invoices-table', [
|
|
|
|
'invoices' => $query
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|