@extends('frontend.layouts.user.index') @section('title', __('Subscription Plans')) @push('styles') @endpush @section('content') @php $currencyCode = siteCurrency('code'); @endphp
@if($current) {{ __('My Subscription') }} @endif {{ __('History') }}
{{-- Billing cycle selector --}}
{{-- Contextual billing hint --}} @if($maxYearlyDiscount)

{{ __('Save up to :d% when billed annually — your best value.', ['d' => $maxYearlyDiscount]) }}

@endif {{-- Plans --}} @if($plans->isEmpty()) @else
@foreach($plans as $idx => $plan) @php $isFeatured = $plan->is_featured; $isCurrent = $current && $current->subscription_plan_id === $plan->id && $current->isActive(); $prices = $plan->prices->keyBy( fn($p) => $p->billing_cycle instanceof \App\Enums\BillingCycle ? $p->billing_cycle->value : (string) $p->billing_cycle ); $monthlyRow = $prices['monthly'] ?? null; $halfRow = $prices['half_yearly'] ?? null; $yearlyRow = $prices['yearly'] ?? null; $monthlyAmt = (float) ($monthlyRow?->price ?? 0); $halfAmt = (float) ($halfRow?->price ?? 0); $yearlyAmt = (float) ($yearlyRow?->price ?? 0); $isFree = $monthlyAmt <= 0; $halfPerMo = $halfAmt > 0 ? round($halfAmt / 6, 2) : 0; $yearPerMo = $yearlyAmt > 0 ? round($yearlyAmt / 12, 2) : 0; $halfNote = $halfRow?->discount ? __(':d% off — :c:a billed every 6 months', ['d' => $halfRow->discount, 'c' => $currencyCode, 'a' => number_format($halfAmt, siteDecimalPlaces())]) : ($halfAmt > 0 ? __(':c:a billed every 6 months', ['c' => $currencyCode, 'a' => number_format($halfAmt, siteDecimalPlaces())]) : ''); $yearNote = $yearlyRow?->discount ? __(':d% off — :c:a billed yearly', ['d' => $yearlyRow->discount, 'c' => $currencyCode, 'a' => number_format($yearlyAmt, siteDecimalPlaces())]) : ($yearlyAmt > 0 ? __(':c:a billed yearly', ['c' => $currencyCode, 'a' => number_format($yearlyAmt, siteDecimalPlaces())]) : ''); // Icon per tier $planIcon = match(true) { $isFree => 'fas fa-seedling', $isFeatured => 'fas fa-crown', default => 'fas fa-rocket', }; // Badge if ($isCurrent) { $badgeVariant = 'current'; $badgeText = __('Current Plan'); $badgeCheck = true; } elseif ($isFeatured) { $badgeVariant = 'featured'; $badgeText = $plan->plan_badge ?: __('Most Popular'); $badgeCheck = false; } elseif ($plan->plan_badge) { $badgeVariant = 'pro'; $badgeText = $plan->plan_badge; $badgeCheck = false; } elseif ($isFree) { $badgeVariant = 'free'; $badgeText = __('Free Forever'); $badgeCheck = false; } else { $badgeVariant = null; $badgeText = null; $badgeCheck = false; } // CTA label if ($isFree) { $ctaLabel = __('Get Started — Free'); } elseif ($plan->trial_days > 0) { $ctaLabel = __('Start :d-Day Free Trial', ['d' => $plan->trial_days]); } else { $ctaLabel = __('Subscribe Now'); } @endphp {{-- Wrapper holds animation; badge is sibling of
--}}
@if($badgeText)
@if($badgeCheck) @elseif($isFeatured) @endif {{ $badgeText }}
@endif
{{-- Plan identity --}}
{{ $plan->name }}
{{ $plan->description ?: __('Access to core platform features.') }}
{{-- Pricing --}}
@if($isFree) {{ __('Free') }} {{ __('forever') }} @else {{ $currencyCode }} {{ number_format($monthlyAmt, siteDecimalPlaces()) }} /{{ __('mo') }} @endif
 
{{-- Trial / grace pills --}} @if($plan->trial_days > 0 || $plan->grace_days > 0)
@if($plan->trial_days > 0) {{ $plan->trial_days }}-{{ __('day free trial') }} @endif @if($plan->grace_days > 0) {{ $plan->grace_days }}-{{ __('day grace period') }} @endif
@endif
{{-- Features --}}
@if($plan->features->isNotEmpty())

{{ __("What's included") }}

    @foreach($plan->features as $feature)
  • {{ $feature->feature_label }} @if(! $feature->isToggle()) {{ $feature->isUnlimited() ? __('Unlimited') : $feature->feature_value }} @endif
  • @endforeach
@endif
{{-- Call to action --}}
@if($isCurrent) {{ __('Active Plan') }} @else @php // Prorated charge / credit per cycle for switch CTAs. $planProration = $proration[$plan->id] ?? null; $isSwitch = (bool) ($current && $current->isActive()); $isUpgrade = $isSwitch && (int) $plan->sort_order > (int) $current->plan->sort_order; $isDowngrade = $isSwitch && (int) $plan->sort_order < (int) $current->plan->sort_order; if ($isUpgrade) { $switchLabel = __('Upgrade to :name', ['name' => $plan->name]); } elseif ($isDowngrade) { $switchLabel = __('Switch to :name', ['name' => $plan->name]); } else { $switchLabel = $ctaLabel; } $protoData = $planProration ? [ 'monthly_charge' => $planProration['monthly']['charge'] ?? 0, 'monthly_credit' => $planProration['monthly']['credit'] ?? 0, 'monthly_full' => $planProration['monthly']['new_plan_price'] ?? 0, 'half_yearly_charge' => $planProration['half_yearly']['charge'] ?? 0, 'half_yearly_credit' => $planProration['half_yearly']['credit'] ?? 0, 'half_yearly_full' => $planProration['half_yearly']['new_plan_price'] ?? 0, 'yearly_charge' => $planProration['yearly']['charge'] ?? 0, 'yearly_credit' => $planProration['yearly']['credit'] ?? 0, 'yearly_full' => $planProration['yearly']['new_plan_price'] ?? 0, 'remaining_days' => $planProration['monthly']['remaining_days'] ?? 0, ] : null; @endphp {{ $isSwitch ? $switchLabel : $ctaLabel }} @if($isSwitch && $planProration && ($planProration['monthly']['credit'] ?? 0) > 0)
{{ __('Prorated — :days days credit applied', ['days' => $planProration['monthly']['remaining_days']]) }}
@endif @endif
{{-- /.sp-card-wrap --}} @endforeach
@endif
{{-- /.card-body --}}
{{-- /.single-form-card --}}
@push('scripts') @endpush @endsection