mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactor for livewire
This commit is contained in:
parent
3a85441c49
commit
843229d9b5
@ -3,7 +3,9 @@
|
|||||||
namespace App\Http\Livewire;
|
namespace App\Http\Livewire;
|
||||||
|
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Client;
|
||||||
use App\Models\ClientGatewayToken;
|
use App\Models\ClientGatewayToken;
|
||||||
|
use App\Models\Company;
|
||||||
use App\Utils\Traits\WithSorting;
|
use App\Utils\Traits\WithSorting;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Livewire\WithPagination;
|
use Livewire\WithPagination;
|
||||||
@ -13,17 +15,23 @@ class PaymentMethodsTable extends Component
|
|||||||
use WithPagination;
|
use WithPagination;
|
||||||
use WithSorting;
|
use WithSorting;
|
||||||
|
|
||||||
public $per_page = 10;
|
public int $per_page = 10;
|
||||||
|
|
||||||
public $client;
|
public Client $client;
|
||||||
|
|
||||||
public $company;
|
public Company $company;
|
||||||
|
|
||||||
public function mount($client)
|
public int $client_id;
|
||||||
|
|
||||||
|
public string $db;
|
||||||
|
|
||||||
|
public function mount()
|
||||||
{
|
{
|
||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->db);
|
||||||
|
|
||||||
$this->client = $client;
|
$this->client = Client::with('company')->find($this->client_id);
|
||||||
|
|
||||||
|
$this->company = $this->client->company;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
namespace App\Http\Livewire;
|
namespace App\Http\Livewire;
|
||||||
|
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Company;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Utils\Traits\WithSorting;
|
use App\Utils\Traits\WithSorting;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
@ -23,17 +24,19 @@ class PaymentsTable extends Component
|
|||||||
use WithSorting;
|
use WithSorting;
|
||||||
use WithPagination;
|
use WithPagination;
|
||||||
|
|
||||||
public $per_page = 10;
|
public int $per_page = 10;
|
||||||
|
|
||||||
public $user;
|
public Company $company;
|
||||||
|
|
||||||
public $company;
|
public int $company_id;
|
||||||
|
|
||||||
|
public string $db;
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->db);
|
||||||
|
|
||||||
$this->user = auth()->user();
|
$this->company = Company::find($this->company_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
namespace App\Http\Livewire;
|
namespace App\Http\Livewire;
|
||||||
|
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Company;
|
||||||
use App\Models\Quote;
|
use App\Models\Quote;
|
||||||
use App\Utils\Traits\WithSorting;
|
use App\Utils\Traits\WithSorting;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
@ -22,15 +23,27 @@ class QuotesTable extends Component
|
|||||||
{
|
{
|
||||||
use WithPagination;
|
use WithPagination;
|
||||||
|
|
||||||
public $per_page = 10;
|
public int $per_page = 10;
|
||||||
|
|
||||||
public $status = [];
|
public array $status = [];
|
||||||
|
|
||||||
public $company;
|
public Company $company;
|
||||||
|
|
||||||
public $sort = 'status_id'; // Default sortBy. Feel free to change or pull from client/company settings.
|
public string $sort = 'status_id';
|
||||||
|
|
||||||
|
public bool $sort_asc = true;
|
||||||
|
|
||||||
|
public int $company_id;
|
||||||
|
|
||||||
|
public string $db;
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
MultiDB::setDb($this->db);
|
||||||
|
|
||||||
|
$this->company = Company::find($this->company_id);
|
||||||
|
}
|
||||||
|
|
||||||
public $sort_asc = true;
|
|
||||||
|
|
||||||
public function sortBy($field)
|
public function sortBy($field)
|
||||||
{
|
{
|
||||||
@ -41,16 +54,11 @@ class QuotesTable extends Component
|
|||||||
$this->sort = $field;
|
$this->sort = $field;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mount()
|
|
||||||
{
|
|
||||||
MultiDB::setDb($this->company->db);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
|
|
||||||
$query = Quote::query()
|
$query = Quote::query()
|
||||||
->with('client.gateway_tokens', 'company', 'client.contacts')
|
->with('client.contacts', 'company')
|
||||||
->orderBy($this->sort, $this->sort_asc ? 'asc' : 'desc');
|
->orderBy($this->sort, $this->sort_asc ? 'asc' : 'desc');
|
||||||
|
|
||||||
if (count($this->status) > 0) {
|
if (count($this->status) > 0) {
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
@section('body')
|
@section('body')
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
@livewire('payment-methods-table', ['client' => $client, 'company' => $company])
|
@livewire('payment-methods-table', ['client_id' => $client->id, 'db' => $company->db])
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
@section('body')
|
@section('body')
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
@livewire('payments-table', ['company' => $company])
|
@livewire('payments-table', ['company_id' => $company->id, 'db' => $company->db])
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
@ -26,6 +26,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col mt-4">
|
<div class="flex flex-col mt-4">
|
||||||
@livewire('quotes-table', ['company' => $company])
|
@livewire('quotes-table', ['company_id' => $company->id, 'db' => $company->db])
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
Loading…
x
Reference in New Issue
Block a user