@extends('layouts.app') @section('title', __('Plan & billing')) @section('page-title', __('Plan & billing')) @section('content') @php $currentPlanId = $subscription?->plan_id; $currentCycle = $subscription?->cycle ?? 'monthly'; $currentPrice = (float) ($subscription?->effectivePrice() ?? 0); @endphp

{{ __('Plan & billing') }}

{{ __('View your current plan and switch — upgrade or downgrade — at any time.') }}

@if(session('status'))
{{ session('status') }}
@endif @if($errors->any())
@endif @php $anyGatewayEnabled = ($gateways['stripe'] ?? false) || ($gateways['paypal'] ?? false); $anyPaidPlan = $plans->contains(fn($p) => ((float) ($p->currentVersion->price_monthly ?? 0)) > 0 || ((float) ($p->currentVersion->price_yearly ?? 0)) > 0); @endphp @if($anyPaidPlan && ! $anyGatewayEnabled)
{{ __('Online payments are not available right now.') }}
{{ __('No payment gateway is configured. Paid plan changes are temporarily disabled — please contact support to upgrade.') }}
@endif {{-- Current subscription summary --}}

{{ __('Current plan') }}

{{ __('Your active subscription details.') }}

@if($subscription)
{{ __('Plan') }}
{{ $subscription->plan?->displayName() ?? '—' }} v{{ $subscription->planVersion?->version }}
@if($subscription->plan?->displayTagline())
{{ $subscription->plan->displayTagline() }}
@endif
{{ __('State') }}
{{ __($subscription->state) }}
{{ __('Cycle') }}
{{ __($subscription->cycle) }}
{{ __('Price') }}
{{ number_format($currentPrice, 2) }} {{ $subscription->currency }}
@if($subscription->trial_ends_at)
{{ __('Trial ends') }}
{{ $subscription->trial_ends_at->format('Y-m-d') }}
@endif @if($subscription->current_period_ends_at)
{{ __('Renews on') }}
{{ $subscription->current_period_ends_at->format('Y-m-d') }}
@endif
@else

{{ __('You don\'t have an active subscription yet. Pick a plan below to get started.') }}

@endif
{{-- Cycle toggle for the plan grid --}}

{{ __('Available plans') }}

@if($plans->isEmpty())
{{ __('No plans are available right now. Please contact support.') }}
@else
@foreach($plans as $plan) @php $version = $plan->currentVersion; $monthly = (float) ($version->price_monthly ?? 0); $yearly = (float) ($version->price_yearly ?? 0); $isCurrent = $currentPlanId === $plan->id; @endphp
@if($isCurrent) {{ __('Current') }} @endif
{{ $plan->displayName() }}
@if($plan->displayTagline())
{{ $plan->displayTagline() }}
@endif
{{ number_format($monthly, 2) }} {{ $version->currency }} / {{ __('mo') }}
{{ number_format($yearly, 2) }} {{ $version->currency }} / {{ __('yr') }}
@if(($version->trial_days ?? 0) > 0 && ! $subscription)
{{ __(':n-day free trial', ['n' => $version->trial_days]) }}
@endif
@php $currentMonthlyEquivalent = $currentCycle === 'yearly' ? ($currentPrice / 12) : $currentPrice; $direction = ! $subscription || ! $subscription->isActive() ? 'choose' : ($isCurrent ? 'cycle' : ($monthly > $currentMonthlyEquivalent ? 'upgrade' : ($monthly < $currentMonthlyEquivalent ? 'downgrade' : 'switch'))); $cardCycle = null; // resolved per cycle inside Alpine: we render two prices and pass cycle hidden field $isPaidMonthly = $monthly > 0; $isPaidYearly = $yearly > 0; $hasGateway = ($gateways['stripe'] ?? false) || ($gateways['paypal'] ?? false); @endphp
@csrf {{-- Gateway picker (only shown if paid plan + at least one gateway enabled) --}} @if($hasGateway && ($isPaidMonthly || $isPaidYearly))
@if(! empty($gateways['stripe'])) @endif @if(! empty($gateways['paypal'])) @endif
@endif @if($direction === 'cycle') @elseif($direction === 'choose') @elseif($direction === 'upgrade') @elseif($direction === 'downgrade') @else @endif
@endforeach
@endif
{{-- Recent activity --}} @if($logs->isNotEmpty())

{{ __('Recent activity') }}

@endif @endsection