@extends('theme::layouts.app', ['title' => $title ?? __('subscription.title|Subscriptions')]) @section('content')
@if(isset($pageHeader))

{{ $pageHeader['title'] }}

{{ $pageHeader['subtitle'] }}

@endif
@forelse ($subscriptions as $subscription) @php $statusDetails = getSubscriptionStatusDetails($subscription->status); $badgeClass = 'bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400'; $isCancelled = !empty($subscription->cancelled_at); $isActive = $subscription->status === getConstant('SUBSCRIPTION_STATUS_ACTIVE'); // Determine the effective expiry date (end_date if set, otherwise next_billing_date) $expiryDate = $subscription->end_date ?? $subscription->next_billing_date; // Status Badge Logic if ($isCancelled && $expiryDate > now()) { // Grace period: Cancelled but still has time left $badgeClass = 'bg-orange-50 text-orange-600 dark:bg-orange-900/20 dark:text-orange-400'; $statusLabel = __('subscription.Pending Cancellation'); } elseif ($statusDetails['class'] == 'bg-success') { $badgeClass = 'bg-green-50 text-green-600 dark:bg-green-900/20 dark:text-green-400'; $statusLabel = $statusDetails['label']; } elseif ($statusDetails['class'] == 'bg-danger') { $badgeClass = 'bg-red-50 text-red-600 dark:bg-red-900/10 dark:text-red-500'; $statusLabel = $statusDetails['label']; } else { $statusLabel = $statusDetails['label']; } @endphp
{{ $isActive ? 'auto_awesome' : 'shield' }}
{{ __('subscription.Subscription Ref') }} {!! $subscription->reference_id !!}
{{ __('subscription.Billing Cycle') }} {{ $subscription->billing_cycle_label ?? __('subscription.Monthly') }}
{{ __('subscription.Price') }} {!! ch_format_price($subscription->total_price) !!}
{{ ($isActive && !$isCancelled) ? __('subscription.Next Billing') : __('subscription.Expires On') }} @if($expiryDate) {{ $expiryDate->format('M d, Y') }} @else - @endif
@if($isActive) {{-- Upgrade logic would go here if available --}} {{-- --}} @endif @if($isCancelled && $expiryDate > now())
@csrf @method('PUT')
@endif settings {{ __('subscription.Manage Billing') }} @if(!$isCancelled && $isActive)
@csrf @method('PUT')
@endif
@empty

{{ __('subscription.No subscriptions found') }}

{{ __('subscription.You don\'t have any active subscriptions.') }}

@endforelse

{{ __('subscription.Need help?') }} {{ __('subscription.Contact billing support') }}

{{ $subscriptions->links() }}
@endsection