mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
* Install livewire/livewire * Table improvements - Cleanup of InvoiceController - Added Livewire package - New Livewire component (InvoicesTable) - New WithSorting trait - Removed rendering invoices from index.blade.php - Removed Yaryabox/Datatables references in InvoiceController * Refactor: Recurring invoices * payments table & sorting improvements * payment methods table * quotes table * credits table * Add turbolinks
49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
use App\Models\Invoice;
|
|
use App\Traits\WithSorting;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
/**
|
|
* @todo: Integrate InvoiceFilters
|
|
*/
|
|
class InvoicesTable extends Component
|
|
{
|
|
use WithPagination, WithSorting;
|
|
|
|
public $per_page = 10;
|
|
|
|
public $status = [];
|
|
|
|
public function statusChange($status)
|
|
{
|
|
if (in_array($status, $this->status)) {
|
|
return $this->status = array_diff($this->status, [$status]);
|
|
}
|
|
|
|
array_push($this->status, $status);
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
$query = Invoice::query();
|
|
$query = $query->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc');
|
|
|
|
// So $status_id will come in three way:
|
|
// paid, unpaid & overdue. Need to transform them to real values.
|
|
|
|
if (count($this->status)) {
|
|
$query = $query->whereIn('status_id', $this->status);
|
|
}
|
|
|
|
$query = $query->paginate($this->per_page);
|
|
|
|
return render('components.livewire.invoices-table', [
|
|
'invoices' => $query
|
|
]);
|
|
}
|
|
}
|