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