fix: subscription / plan switch, etc
This commit is contained in:
@@ -10,14 +10,19 @@ class Index extends Component
|
||||
{
|
||||
public InstanceSettings $settings;
|
||||
public bool $alreadySubscribed = false;
|
||||
public function mount() {
|
||||
public function mount()
|
||||
{
|
||||
if (!isCloud()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
if (data_get(currentTeam(), 'subscription')) {
|
||||
return redirect()->route('subscription.show');
|
||||
}
|
||||
$this->settings = InstanceSettings::get();
|
||||
$this->alreadySubscribed = currentTeam()->subscription()->exists();
|
||||
}
|
||||
public function stripeCustomerPortal() {
|
||||
public function stripeCustomerPortal()
|
||||
{
|
||||
$session = getStripeCustomerPortalSession(currentTeam());
|
||||
if (is_null($session)) {
|
||||
return;
|
||||
|
||||
@@ -11,6 +11,9 @@ class Show extends Component
|
||||
if (!isCloud()) {
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
if (!data_get(currentTeam(), 'subscription')) {
|
||||
return redirect()->route('subscription.index');
|
||||
}
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
|
||||
@@ -30,8 +30,7 @@ class Subscription extends Model
|
||||
if (in_array($subscription, $ultimate)) {
|
||||
return 'ultimate';
|
||||
}
|
||||
}
|
||||
if (isStripe()) {
|
||||
} else if (isStripe()) {
|
||||
if (!$this->stripe_plan_id) {
|
||||
return 'zero';
|
||||
}
|
||||
@@ -55,7 +54,8 @@ class Subscription extends Model
|
||||
};
|
||||
})->first();
|
||||
if ($stripePlanId) {
|
||||
return Str::of($stripePlanId)->after('stripe_price_id_')->before('_')->lower();
|
||||
raY($stripePlanId);
|
||||
return str($stripePlanId)->after('stripe_price_id_')->before('_')->lower();
|
||||
}
|
||||
}
|
||||
return 'zero';
|
||||
|
||||
@@ -159,6 +159,9 @@ class User extends Authenticatable implements SendsEmail
|
||||
|
||||
public function role()
|
||||
{
|
||||
if (data_get($this, 'pivot')) {
|
||||
return $this->pivot->role;
|
||||
}
|
||||
return auth()->user()->teams->where('id', currentTeam()->id)->first()->pivot->role;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user