1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Make all livewire components MultiDB aware

This commit is contained in:
David Bomba 2021-06-07 11:06:31 +10:00
parent 01a5421bab
commit 8a985c6954
26 changed files with 104 additions and 19 deletions

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use App\Models\Credit; use App\Models\Credit;
use App\Utils\Traits\WithSorting; use App\Utils\Traits\WithSorting;
use Livewire\Component; use Livewire\Component;
@ -24,6 +25,13 @@ class CreditsTable extends Component
public $per_page = 10; public $per_page = 10;
public $company;
public function mount()
{
MultiDB::setDb($this->company->db);
}
public function render() public function render()
{ {
$query = Credit::query() $query = Credit::query()

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use App\Models\Client; use App\Models\Client;
use App\Utils\Traits\WithSorting; use App\Utils\Traits\WithSorting;
use Livewire\Component; use Livewire\Component;
@ -25,8 +26,13 @@ class DocumentsTable extends Component
public $per_page = 10; public $per_page = 10;
public $company;
public function mount($client) public function mount($client)
{ {
MultiDB::setDb($this->company->db);
$this->client = $client; $this->client = $client;
} }

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use App\Models\Invoice; use App\Models\Invoice;
use App\Utils\Traits\WithSorting; use App\Utils\Traits\WithSorting;
use Carbon\Carbon; use Carbon\Carbon;
@ -26,8 +27,12 @@ class InvoicesTable extends Component
public $status = []; public $status = [];
public $company;
public function mount() public function mount()
{ {
MultiDB::setDb($this->company->db);
$this->sort_asc = false; $this->sort_asc = false;
$this->sort_field = 'date'; $this->sort_field = 'date';

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use Livewire\Component; use Livewire\Component;
class PayNowDropdown extends Component class PayNowDropdown extends Component
@ -20,8 +21,12 @@ class PayNowDropdown extends Component
public $methods; public $methods;
public $company;
public function mount(int $total) public function mount(int $total)
{ {
MultiDB::setDb($this->company->db);
$this->total = $total; $this->total = $total;
$this->methods = auth()->user()->client->service()->getPaymentMethods($total); $this->methods = auth()->user()->client->service()->getPaymentMethods($total);

View File

@ -5,6 +5,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use App\Models\ClientGatewayToken; use App\Models\ClientGatewayToken;
use App\Utils\Traits\WithSorting; use App\Utils\Traits\WithSorting;
use Livewire\Component; use Livewire\Component;
@ -16,10 +17,16 @@ class PaymentMethodsTable extends Component
use WithSorting; use WithSorting;
public $per_page = 10; public $per_page = 10;
public $client; public $client;
public $company;
public function mount($client) public function mount($client)
{ {
MultiDB::setDb($this->company->db);
$this->client = $client; $this->client = $client;
} }

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
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,11 +24,17 @@ class PaymentsTable extends Component
use WithPagination; use WithPagination;
public $per_page = 10; public $per_page = 10;
public $user; public $user;
public $company;
public function mount() public function mount()
{ {
MultiDB::setDb($this->company->db);
$this->user = auth()->user(); $this->user = auth()->user();
} }
public function render() public function render()

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use App\Models\Quote; use App\Models\Quote;
use App\Utils\Traits\WithSorting; use App\Utils\Traits\WithSorting;
use Livewire\Component; use Livewire\Component;
@ -23,8 +24,17 @@ class QuotesTable extends Component
use WithPagination; use WithPagination;
public $per_page = 10; public $per_page = 10;
public $status = []; public $status = [];
public $company;
public function mount()
{
MultiDB::setDb($this->company->db);
}
public function render() public function render()
{ {
$query = Quote::query() $query = Quote::query()

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use App\Models\RecurringInvoice; use App\Models\RecurringInvoice;
use Livewire\Component; use Livewire\Component;
@ -22,6 +23,18 @@ class RecurringInvoiceCancellation extends Component
*/ */
public $invoice; public $invoice;
public $company;
public function mount()
{
MultiDB::setDb($this->company->db);
}
public function render()
{
return render('components.livewire.recurring-invoice-cancellation');
}
public function processCancellation() public function processCancellation()
{ {
if ($this->invoice->subscription) { if ($this->invoice->subscription) {
@ -31,8 +44,5 @@ class RecurringInvoiceCancellation extends Component
return redirect()->route('client.recurring_invoices.request_cancellation', ['recurring_invoice' => $this->invoice->hashed_id]); return redirect()->route('client.recurring_invoices.request_cancellation', ['recurring_invoice' => $this->invoice->hashed_id]);
} }
public function render()
{
return render('components.livewire.recurring-invoice-cancellation');
}
} }

View File

@ -13,6 +13,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use App\Models\ClientContact; use App\Models\ClientContact;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -65,7 +66,12 @@ class RequiredClientInfo extends Component
public $show_form = false; public $show_form = false;
public function mount() {} public $company;
public function mount()
{
MultiDB::setDb($this->company->db);
}
public function handleSubmit(array $data): bool public function handleSubmit(array $data): bool
{ {

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use App\Models\ClientContact; use App\Models\ClientContact;
use App\Models\Subscription; use App\Models\Subscription;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
@ -71,8 +72,12 @@ class SubscriptionPlanSwitch extends Component
*/ */
public $hash; public $hash;
public $company;
public function mount() public function mount()
{ {
MultiDB::setDb($this->company->db);
$this->total = $this->amount; $this->total = $this->amount;
$this->methods = $this->contact->client->service()->getPaymentMethods($this->amount); $this->methods = $this->contact->client->service()->getPaymentMethods($this->amount);

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use App\Models\RecurringInvoice; use App\Models\RecurringInvoice;
use App\Utils\Traits\WithSorting; use App\Utils\Traits\WithSorting;
use Livewire\Component; use Livewire\Component;
@ -24,6 +25,13 @@ class SubscriptionRecurringInvoicesTable extends Component
public $per_page = 10; public $per_page = 10;
public $company;
public function mount()
{
MultiDB::setDb($this->company->db);
}
public function render() public function render()
{ {
$query = RecurringInvoice::query() $query = RecurringInvoice::query()

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use App\Models\Task; use App\Models\Task;
use App\Utils\Traits\WithSorting; use App\Utils\Traits\WithSorting;
use Livewire\Component; use Livewire\Component;
@ -24,6 +25,13 @@ class TasksTable extends Component
public $per_page = 10; public $per_page = 10;
public $company;
public function mount()
{
MultiDB::setDb($this->company->db);
}
public function render() public function render()
{ {
$query = Task::query() $query = Task::query()

View File

@ -13,6 +13,6 @@
@section('body') @section('body')
<div class="flex flex-col"> <div class="flex flex-col">
@livewire('credits-table') @livewire('credits-table', ['company' => $company])
</div> </div>
@endsection @endsection

View File

@ -14,5 +14,5 @@
@csrf @csrf
</form> </form>
@livewire('documents-table', ['client' => $client]) @livewire('documents-table', ['client' => $client, 'company' => $company])
@endsection @endsection

View File

@ -20,6 +20,6 @@
</form> </form>
</div> </div>
<div class="flex flex-col mt-4"> <div class="flex flex-col mt-4">
@livewire('invoices-table') @livewire('invoices-table', ['company' => $company])
</div> </div>
@endsection @endsection

View File

@ -19,7 +19,7 @@
<div class="col-span-6 md:col-start-2 md:col-span-4"> <div class="col-span-6 md:col-start-2 md:col-span-4">
<div class="flex justify-end"> <div class="flex justify-end">
<div class="flex justify-end mb-2"> <div class="flex justify-end mb-2">
@livewire('pay-now-dropdown', ['total' => $total]) @livewire('pay-now-dropdown', ['total' => $total, 'company' => $company])
</div> </div>
</div> </div>

View File

@ -47,7 +47,7 @@
@if($settings->client_portal_allow_under_payment || $settings->client_portal_allow_over_payment) @if($settings->client_portal_allow_under_payment || $settings->client_portal_allow_over_payment)
<button class="button button-primary bg-primary">{{ ctrans('texts.pay_now') }}</button> <button class="button button-primary bg-primary">{{ ctrans('texts.pay_now') }}</button>
@else @else
@livewire('pay-now-dropdown', ['total' => $invoice->partial > 0 ? $invoice->partial : $invoice->balance]) @livewire('pay-now-dropdown', ['total' => $invoice->partial > 0 ? $invoice->partial : $invoice->balance, 'company' => $company])
@endif @endif
</div> </div>
</div> </div>

View File

@ -11,7 +11,7 @@
@endpush @endpush
@section('body') @section('body')
@livewire('required-client-info', ['fields' => method_exists($gateway, 'getClientRequiredFields') ? $gateway->getClientRequiredFields() : [], 'contact' => auth('contact')->user(), 'countries' => $countries]) @livewire('required-client-info', ['fields' => method_exists($gateway, 'getClientRequiredFields') ? $gateway->getClientRequiredFields() : [], 'contact' => auth('contact')->user(), 'countries' => $countries, 'company' => $company])
<div class="container mx-auto grid grid-cols-12 opacity-25 pointer-events-none" data-ref="gateway-container"> <div class="container mx-auto grid grid-cols-12 opacity-25 pointer-events-none" data-ref="gateway-container">
<div class="col-span-12 lg:col-span-6 lg:col-start-4 overflow-hidden bg-white shadow rounded-lg"> <div class="col-span-12 lg:col-span-6 lg:col-start-4 overflow-hidden bg-white shadow rounded-lg">

View File

@ -3,6 +3,6 @@
@section('body') @section('body')
<div class="flex flex-col"> <div class="flex flex-col">
@livewire('payment-methods-table', ['client' => $client]) @livewire('payment-methods-table', ['client' => $client, 'company' => $company])
</div> </div>
@endsection @endsection

View File

@ -3,6 +3,6 @@
@section('body') @section('body')
<div class="flex flex-col"> <div class="flex flex-col">
@livewire('payments-table') @livewire('payments-table', ['company' => $company])
</div> </div>
@endsection @endsection

View File

@ -22,6 +22,6 @@
</form> </form>
</div> </div>
<div class="flex flex-col mt-4"> <div class="flex flex-col mt-4">
@livewire('quotes-table') @livewire('quotes-table', ['company' => $company])
</div> </div>
@endsection @endsection

View File

@ -34,7 +34,7 @@
</div> </div>
<div class="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse"> <div class="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
<div class="flex w-full rounded-md shadow-sm sm:ml-3 sm:w-auto"> <div class="flex w-full rounded-md shadow-sm sm:ml-3 sm:w-auto">
@livewire('recurring-invoice-cancellation', ['invoice' => $invoice]) @livewire('recurring-invoice-cancellation', ['invoice' => $invoice, 'company' => $company])
</div> </div>
<div class="mt-3 flex w-full rounded-md shadow-sm sm:mt-0 sm:w-auto"> <div class="mt-3 flex w-full rounded-md shadow-sm sm:mt-0 sm:w-auto">
<button @click="open = false" type="button" class="button button-secondary button-block"> <button @click="open = false" type="button" class="button button-secondary button-block">

View File

@ -3,6 +3,6 @@
@section('body') @section('body')
<div class="flex flex-col"> <div class="flex flex-col">
@livewire('recurring-invoices-table') @livewire('recurring-invoices-table', ['company' => $company])
</div> </div>
@endsection @endsection

View File

@ -3,6 +3,6 @@
@section('body') @section('body')
<div class="flex flex-col"> <div class="flex flex-col">
@livewire('subscription-recurring-invoices-table') @livewire('subscription-recurring-invoices-table', ['company' => $company])
</div> </div>
@endsection @endsection

View File

@ -42,7 +42,7 @@
</div> </div>
<!-- Payment box --> <!-- Payment box -->
@livewire('subscription-plan-switch', compact('recurring_invoice', 'subscription', 'target', 'contact', 'amount')) @livewire('subscription-plan-switch', compact('recurring_invoice', 'subscription', 'target', 'contact', 'amount', 'company'))
</div> </div>
@endsection @endsection

View File

@ -3,6 +3,6 @@
@section('body') @section('body')
<div class="flex flex-col"> <div class="flex flex-col">
@livewire('tasks-table') @livewire('tasks-table', ['company' => $company])
</div> </div>
@endsection @endsection