move subscription to livewire + show manage subscription button for people already subscribed once
This commit is contained in:
parent
68091b44fc
commit
a4f1fcba58
@ -46,15 +46,6 @@ public function link()
|
|||||||
}
|
}
|
||||||
return redirect()->route('login')->with('error', 'Invalid credentials.');
|
return redirect()->route('login')->with('error', 'Invalid credentials.');
|
||||||
}
|
}
|
||||||
public function subscription()
|
|
||||||
{
|
|
||||||
if (!isCloud()) {
|
|
||||||
abort(404);
|
|
||||||
}
|
|
||||||
return view('subscription.index', [
|
|
||||||
'settings' => InstanceSettings::get(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function license()
|
public function license()
|
||||||
{
|
{
|
||||||
|
30
app/Http/Livewire/Subscription/Show.php
Normal file
30
app/Http/Livewire/Subscription/Show.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire\Subscription;
|
||||||
|
|
||||||
|
use App\Models\InstanceSettings;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Show extends Component
|
||||||
|
{
|
||||||
|
public InstanceSettings $settings;
|
||||||
|
public bool $alreadySubscribed = false;
|
||||||
|
public function mount() {
|
||||||
|
if (!isCloud()) {
|
||||||
|
return redirect('/');
|
||||||
|
}
|
||||||
|
$this->settings = InstanceSettings::get();
|
||||||
|
$this->alreadySubscribed = currentTeam()->subscription()->exists();
|
||||||
|
}
|
||||||
|
public function stripeCustomerPortal() {
|
||||||
|
$session = getStripeCustomerPortalSession(currentTeam());
|
||||||
|
if (is_null($session)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return redirect($session->url);
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.subscription.show')->layout('layouts.subscription');
|
||||||
|
}
|
||||||
|
}
|
@ -110,7 +110,10 @@ function getStripeCustomerPortalSession(Team $team)
|
|||||||
{
|
{
|
||||||
Stripe::setApiKey(config('subscription.stripe_api_key'));
|
Stripe::setApiKey(config('subscription.stripe_api_key'));
|
||||||
$return_url = route('team.index');
|
$return_url = route('team.index');
|
||||||
$stripe_customer_id = $team->subscription->stripe_customer_id;
|
$stripe_customer_id = data_get($team,'subscription.stripe_customer_id');
|
||||||
|
if (!$stripe_customer_id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
$session = \Stripe\BillingPortal\Session::create([
|
$session = \Stripe\BillingPortal\Session::create([
|
||||||
'customer' => $stripe_customer_id,
|
'customer' => $stripe_customer_id,
|
||||||
'return_url' => $return_url,
|
'return_url' => $return_url,
|
||||||
|
49
resources/views/livewire/subscription/show.blade.php
Normal file
49
resources/views/livewire/subscription/show.blade.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
@if ($settings->is_resale_license_active)
|
||||||
|
@if (auth()->user()->isAdminFromSession())
|
||||||
|
<div class="flex justify-center mx-10">
|
||||||
|
<div x-data>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<h1>Subscription</h1>
|
||||||
|
<livewire:switch-team />
|
||||||
|
@if (subscriptionProvider() === 'stripe' && $alreadySubscribed)
|
||||||
|
<x-forms.button wire:click='stripeCustomerPortal'>Manage My Subscription</x-forms.button>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center pb-8">
|
||||||
|
<span>Currently active team: <span
|
||||||
|
class="text-warning">{{ session('currentTeam.name') }}</span></span>
|
||||||
|
</div>
|
||||||
|
@if (request()->query->get('cancelled'))
|
||||||
|
<div class="mb-6 rounded alert alert-error">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 stroke-current shrink-0" fill="none"
|
||||||
|
viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||||
|
</svg>
|
||||||
|
<span>Something went wrong with your subscription. Please try again or contact
|
||||||
|
support.</span>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (config('subscription.provider') !== null)
|
||||||
|
<livewire:subscription.pricing-plans />
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="flex flex-col justify-center mx-10">
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<h1>Subscription</h1>
|
||||||
|
<livewire:switch-team />
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center pb-8">
|
||||||
|
<span>Currently active team: <span class="text-warning">{{ session('currentTeam.name') }}</span></span>
|
||||||
|
</div>
|
||||||
|
<div>You are not an admin or have been removed from this team. If this does not make sense, please <span
|
||||||
|
class="text-white underline cursor-pointer" wire:click="help" onclick="help.showModal()">contact
|
||||||
|
us</span>.</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@else
|
||||||
|
<div class="px-10">Resale license is not active. Please contact your instance admin.</div>
|
||||||
|
@endif
|
@ -1,46 +0,0 @@
|
|||||||
<x-layout-subscription>
|
|
||||||
@if ($settings->is_resale_license_active)
|
|
||||||
@if (auth()->user()->isAdminFromSession())
|
|
||||||
<div class="flex justify-center mx-10">
|
|
||||||
<div x-data>
|
|
||||||
<div class="flex gap-2">
|
|
||||||
<h1>Subscription</h1>
|
|
||||||
<livewire:switch-team />
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center pb-8">
|
|
||||||
<span>Currently active team: <span
|
|
||||||
class="text-warning">{{ session('currentTeam.name') }}</span></span>
|
|
||||||
</div>
|
|
||||||
@if (request()->query->get('cancelled'))
|
|
||||||
<div class="mb-6 rounded alert alert-error">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 stroke-current shrink-0" fill="none"
|
|
||||||
viewBox="0 0 24 24">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
||||||
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
||||||
</svg>
|
|
||||||
<span>Something went wrong with your subscription. Please try again or contact
|
|
||||||
support.</span>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
@if (config('subscription.provider') !== null)
|
|
||||||
<livewire:subscription.pricing-plans />
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@else
|
|
||||||
<div class="flex flex-col justify-center mx-10">
|
|
||||||
<div class="flex gap-2">
|
|
||||||
<h1>Subscription</h1>
|
|
||||||
<livewire:switch-team />
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center pb-8">
|
|
||||||
<span>Currently active team: <span
|
|
||||||
class="text-warning">{{ session('currentTeam.name') }}</span></span>
|
|
||||||
</div>
|
|
||||||
<div>You are not an admin or have been removed from this team. If this does not make sense, please <span class="text-white underline cursor-pointer" wire:click="help" onclick="help.showModal()">contact us</span>.</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
@else
|
|
||||||
<div class="px-10" >Resale license is not active. Please contact your instance admin.</div>
|
|
||||||
@endif
|
|
||||||
</x-layout-subscription>
|
|
@ -18,6 +18,7 @@
|
|||||||
use App\Http\Livewire\Server\PrivateKey\Show as PrivateKeyShow;
|
use App\Http\Livewire\Server\PrivateKey\Show as PrivateKeyShow;
|
||||||
use App\Http\Livewire\Server\Proxy\Show as ProxyShow;
|
use App\Http\Livewire\Server\Proxy\Show as ProxyShow;
|
||||||
use App\Http\Livewire\Server\Show;
|
use App\Http\Livewire\Server\Show;
|
||||||
|
use App\Http\Livewire\Subscription\Show as SubscriptionShow;
|
||||||
use App\Http\Livewire\Waitlist\Index as WaitlistIndex;
|
use App\Http\Livewire\Waitlist\Index as WaitlistIndex;
|
||||||
use App\Models\GithubApp;
|
use App\Models\GithubApp;
|
||||||
use App\Models\GitlabApp;
|
use App\Models\GitlabApp;
|
||||||
@ -133,7 +134,7 @@
|
|||||||
Route::middleware(['throttle:force-password-reset'])->group(function () {
|
Route::middleware(['throttle:force-password-reset'])->group(function () {
|
||||||
Route::get('/force-password-reset', [Controller::class, 'force_passoword_reset'])->name('auth.force-password-reset');
|
Route::get('/force-password-reset', [Controller::class, 'force_passoword_reset'])->name('auth.force-password-reset');
|
||||||
});
|
});
|
||||||
Route::get('/subscription', [Controller::class, 'subscription'])->name('subscription.index');
|
Route::get('/subscription', SubscriptionShow::class)->name('subscription.index');
|
||||||
// Route::get('/help', Help::class)->name('help');
|
// Route::get('/help', Help::class)->name('help');
|
||||||
Route::get('/settings', [Controller::class, 'settings'])->name('settings.configuration');
|
Route::get('/settings', [Controller::class, 'settings'])->name('settings.configuration');
|
||||||
Route::get('/settings/license', [Controller::class, 'license'])->name('settings.license');
|
Route::get('/settings/license', [Controller::class, 'license'])->name('settings.license');
|
||||||
|
Loading…
Reference in New Issue
Block a user