diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index e4cfaaeef984..c24f0139410c 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -265,6 +265,9 @@ 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)) { $currency = Cache::get('currencies')->filter(function ($item){ @@ -274,6 +277,16 @@ class BillingPortalPurchase extends Component if($currency) $data['settings']->currency_id = $currency->id; + } + elseif($this->subscription->group_settings && property_exists($this->subscription->group_settings->settings, 'currency_id')) { + + $currency = Cache::get('currencies')->filter(function ($item){ + return $item->id == $this->subscription->group_settings->settings->currency_id; + })->first(); + + if($currency) + $data['settings']->currency_id = $currency->id; + } if (array_key_exists('locale', $this->request_data)) { diff --git a/app/Models/Subscription.php b/app/Models/Subscription.php index da92f7add006..6bac62e44341 100644 --- a/app/Models/Subscription.php +++ b/app/Models/Subscription.php @@ -83,6 +83,11 @@ class Subscription extends BaseModel return $this->belongsTo(User::class)->withTrashed(); } + public function group_settings() + { + return $this->belongsTo(GroupSetting::class, 'group_id', 'id'); + } + public function nextDateByInterval($date, $frequency_id) { switch ($frequency_id) {