invoiceninja/app/Http/Livewire/CreditsTable.php

56 lines
1.4 KiB
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2022-04-27 13:20:41 +10:00
* @copyright Copyright (c) 2022. 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;
use App\Models\Credit;
use App\Utils\Traits\WithSorting;
use Livewire\Component;
use Livewire\WithPagination;
class CreditsTable extends Component
{
use WithPagination;
use WithSorting;
public $per_page = 10;
public $company;
public function mount()
{
MultiDB::setDb($this->company->db);
}
public function render()
{
$query = Credit::query()
2022-09-16 14:20:46 +10:00
->where('client_id', auth()->guard('contact')->user()->client_id)
2021-07-04 07:46:25 +10:00
->where('company_id', $this->company->id)
2021-02-11 14:14:11 +01:00
->where('status_id', '<>', Credit::STATUS_DRAFT)
2021-10-04 09:36:30 +11:00
->where('is_deleted', 0)
->where(function ($query) {
2021-10-05 13:12:21 +11:00
$query->whereDate('due_date', '>=', now())
2021-12-12 07:55:35 +11:00
->orWhereNull('due_date');
//->orWhere('due_date', '=', '');
2021-07-04 07:46:25 +10:00
})
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc')
2021-09-10 21:48:09 +02:00
->withTrashed()
->paginate($this->per_page);
return render('components.livewire.credits-table', [
'credits' => $query,
]);
}
}