Reduce object sizes in Livewire

This commit is contained in:
David Bomba 2022-12-22 16:53:48 +11:00
parent 3e4926d88e
commit 9e84f6c10f
4 changed files with 13 additions and 11 deletions

View File

@ -188,6 +188,7 @@ class BillingPortalPurchase extends Component
MultiDB::setDb($this->db); MultiDB::setDb($this->db);
$this->subscription = Subscription::with('company')->find($this->subscription); $this->subscription = Subscription::with('company')->find($this->subscription);
$this->company = $this->subscription->company; $this->company = $this->subscription->company;
$this->quantity = 1; $this->quantity = 1;
@ -230,10 +231,10 @@ class BillingPortalPurchase extends Component
$this->steps['existing_user'] = false; $this->steps['existing_user'] = false;
$contact = $this->createBlankClient(); $this->contact = $this->createBlankClient();
if ($contact && $contact instanceof ClientContact) { if ($this->contact && $this->contact instanceof ClientContact) {
$this->getPaymentMethods($contact); $this->getPaymentMethods($this->contact);
} }
} }
@ -270,9 +271,6 @@ class BillingPortalPurchase extends Component
} }
} }
// nlog($this->subscription->group_settings->settings);
// nlog($this->subscription->group_settings->settings->currency_id);
if(array_key_exists('currency_id', $this->request_data)) { if(array_key_exists('currency_id', $this->request_data)) {
$currency = Cache::get('currencies')->filter(function ($item){ $currency = Cache::get('currencies')->filter(function ($item){
@ -335,8 +333,6 @@ class BillingPortalPurchase extends Component
else else
$this->steps['fetched_payment_methods'] = true; $this->steps['fetched_payment_methods'] = true;
nlog("payment methods price = {$this->price}");
$this->methods = $contact->client->service()->getPaymentMethods($this->price); $this->methods = $contact->client->service()->getPaymentMethods($this->price);
$this->heading_text = ctrans('texts.payment_methods'); $this->heading_text = ctrans('texts.payment_methods');

View File

@ -130,6 +130,8 @@ class BillingPortalPurchasev2 extends Component
*/ */
public $company; public $company;
public $db;
/** /**
* Campaign reference. * Campaign reference.
* *
@ -157,7 +159,11 @@ class BillingPortalPurchasev2 extends Component
public function mount() public function mount()
{ {
MultiDB::setDb($this->company->db); MultiDB::setDb($this->db);
$this->subscription = Subscription::with('company')->find($this->subscription);
$this->company = $this->subscription->company;
if(auth()->guard('contact')->check()){ if(auth()->guard('contact')->check()){
$this->email = auth()->guard('contact')->user()->email; $this->email = auth()->guard('contact')->user()->email;

View File

@ -2,7 +2,7 @@
@section('meta_title', ctrans('texts.purchase')) @section('meta_title', ctrans('texts.purchase'))
@section('body') @section('body')
@livewire('billing-portal-purchase', ['subscription' => $subscription->id, 'db' => $subscription->company->db, 'contact' => auth()->guard('contact')->user(), 'hash' => $hash, 'request_data' => $request_data, 'campaign' => request()->query('campaign') ?? null]) @livewire('billing-portal-purchase', ['subscription' => $subscription->id, 'db' => $subscription->company->db, 'hash' => $hash, 'request_data' => $request_data, 'campaign' => request()->query('campaign') ?? null])
@stop @stop
@push('footer') @push('footer')

View File

@ -2,7 +2,7 @@
@section('meta_title', ctrans('texts.purchase')) @section('meta_title', ctrans('texts.purchase'))
@section('body') @section('body')
@livewire('billing-portal-purchasev2', ['subscription' => $subscription, 'company' => $subscription->company, 'contact' => auth()->guard('contact')->user(), 'hash' => $hash, 'request_data' => $request_data, 'campaign' => request()->query('campaign') ?? null]) @livewire('billing-portal-purchasev2', ['subscription' => $subscription->id, 'db' => $subscription->company->db, 'hash' => $hash, 'request_data' => $request_data, 'campaign' => request()->query('campaign') ?? null])
@stop @stop
@push('footer') @push('footer')