coolify/app/Livewire/Subscription/Index.php

45 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2023-12-07 19:06:32 +01:00
namespace App\Livewire\Subscription;
use App\Models\InstanceSettings;
2023-12-27 16:45:01 +01:00
use App\Providers\RouteServiceProvider;
use Livewire\Component;
2024-01-07 16:23:41 +01:00
class Index extends Component
{
public InstanceSettings $settings;
2024-06-10 22:43:34 +02:00
public bool $alreadySubscribed = false;
2024-06-10 22:43:34 +02:00
2024-02-23 12:59:14 +01:00
public function mount()
{
2024-06-10 22:43:34 +02:00
if (! isCloud()) {
2023-12-27 16:45:01 +01:00
return redirect(RouteServiceProvider::HOME);
}
2024-04-05 18:47:07 +02:00
if (auth()->user()?->isMember()) {
return redirect()->route('dashboard');
}
2024-03-30 00:23:48 +01:00
if (data_get(currentTeam(), 'subscription') && isSubscriptionActive()) {
2024-02-23 12:59:14 +01:00
return redirect()->route('subscription.show');
}
2024-07-12 15:45:36 +02:00
$this->settings = \App\Models\InstanceSettings::get();
$this->alreadySubscribed = currentTeam()->subscription()->exists();
}
2024-06-10 22:43:34 +02:00
2024-02-23 12:59:14 +01:00
public function stripeCustomerPortal()
{
$session = getStripeCustomerPortalSession(currentTeam());
if (is_null($session)) {
return;
}
2024-06-10 22:43:34 +02:00
return redirect($session->url);
}
2024-06-10 22:43:34 +02:00
public function render()
{
2024-03-21 14:30:35 +01:00
return view('livewire.subscription.index');
}
}