1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Http/Livewire/CreditsTable.php

57 lines
1.4 KiB
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
2021-06-16 08:58:16 +02: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()
{
2021-07-03 23:46:25 +02:00
$query = Credit::query()
->where('client_id', auth()->guard('contact')->user()->client->id)
2021-07-03 23:46:25 +02:00
->where('company_id', $this->company->id)
2021-02-11 14:14:11 +01:00
->where('status_id', '<>', Credit::STATUS_DRAFT)
2021-10-04 00:36:30 +02:00
->where('is_deleted', 0)
2021-07-03 23:46:25 +02:00
->where(function ($query){
2021-10-05 04:12:21 +02:00
$query->whereDate('due_date', '>=', now())
2021-12-11 21:55:35 +01:00
->orWhereNull('due_date');
//->orWhere('due_date', '=', '');
2021-07-03 23:46:25 +02: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,
]);
}
}