@extends('layouts.app')
@section('title', 'Subscription & Billing')
@push('styles')
@endpush
@section('content')
{{-- Flash Messages --}}
@if(session('success'))
{{ $currentPlan->name ?? 'Free Plan' }}
@if(($tenant->plan ?? 'free') === 'free')
You're on the free plan. Upgrade to unlock more features and higher limits.
@else
@php $cancelled = $tenant->settings['subscription_cancelled'] ?? false; @endphp
@if($cancelled)
Your subscription is cancelled and will revert to Free at the end of the billing period.
@else
Your subscription is active. Thank you for being a subscriber!
@endif
@endif
{{-- Usage Stats --}}
Current Usage
@php
$usageItems = [
['label' => 'Products', 'icon' => 'fa-boxes-stacked', 'used' => $usage['products'], 'limit' => $usage['products_limit']],
['label' => 'Staff Members', 'icon' => 'fa-user-group', 'used' => $usage['staff'], 'limit' => $usage['staff_limit']],
['label' => 'Order Forms', 'icon' => 'fa-file-lines', 'used' => $usage['forms'], 'limit' => $usage['forms_limit']],
['label' => 'Orders (this month)', 'icon' => 'fa-receipt', 'used' => $usage['orders_this_month'], 'limit' => $usage['orders_limit']],
];
@endphp
@foreach($usageItems as $item)
@php
$isUnlimited = $item['limit'] == -1;
$pct = $isUnlimited ? 0 : ($item['limit'] > 0 ? min(100, round($item['used'] / $item['limit'] * 100)) : 0);
$barColor = $pct >= 90 ? 'red' : ($pct >= 70 ? 'yellow' : 'green');
@endphp
{{ $item['label'] }}
{{ number_format($item['used']) }} / {{ $isUnlimited ? 'Unlimited' : number_format($item['limit']) }}
@endforeach
{{-- Billing Cycle Toggle --}}
@foreach($plans as $plan)
@php
$planKey = str_replace('inventory-', '', $plan->slug);
$isCurrent = $planKey === ($tenant->plan ?? 'free');
$isRecommended = $planKey === 'growth' && ($tenant->plan ?? 'free') === 'free';
$limits = $plan->limits ?? [];
$features = $plan->features ?? [];
$monthlyPrice = $plan->price_monthly ?? 0;
$yearlyPrice = $plan->price_yearly > 0 ? $plan->price_yearly : round($monthlyPrice * 12 * 0.8);
$isFree = $monthlyPrice == 0;
@endphp
@if($isCurrent)
Current Plan
@elseif($isRecommended)
Recommended
@endif
{{ $plan->name }}
{{ $plan->description ?? 'Perfect for getting started.' }}
@if($isFree)
Free
@else
{{ $currency }}{{ number_format($monthlyPrice) }}/month
{{ $currency }}{{ number_format($yearlyPrice) }}/year
{{ $currency }}{{ number_format(round($yearlyPrice / 12)) }}/month billed yearly
@endif
- {{ ($limits['max_products'] ?? 50) == -1 ? 'Unlimited' : number_format($limits['max_products'] ?? 50) }} Products
- {{ ($limits['max_staff'] ?? 2) == -1 ? 'Unlimited' : number_format($limits['max_staff'] ?? 2) }} Staff Members
- {{ ($limits['max_forms'] ?? 3) == -1 ? 'Unlimited' : number_format($limits['max_forms'] ?? 3) }} Order Forms
- {{ ($limits['max_orders_per_month'] ?? 100) == -1 ? 'Unlimited' : number_format($limits['max_orders_per_month'] ?? 100) }} Orders/month
@if($limits['analytics_dashboard'] ?? false)
- Advanced Analytics
@else
- Advanced Analytics
@endif
@if($limits['wordpress_plugin'] ?? false)
- WordPress Plugin
@else
- WordPress Plugin
@endif
@if(in_array('priority_support', $features))
- Priority Support
@endif
@if(in_array('custom_domain', $features))
- Custom Domain
@endif
@if(in_array('api_access', $features))
- API Access
@endif
@if($isCurrent)
Current Plan
@elseif($isFree)
@else
@endif
@endforeach
{{-- Cancel Subscription --}}
@if(($tenant->plan ?? 'free') !== 'free' && !($tenant->settings['subscription_cancelled'] ?? false))
Billing History
@if($payments->count() > 0)
| Date |
Reference |
Plan |
Cycle |
Amount |
Gateway |
Status |
Invoice |
@foreach($payments as $payment)
@php $isComp = ($payment->gateway ?? '') === 'admin_override'; @endphp
| {{ $payment->created_at->format('M d, Y H:i') }} |
{{ $payment->reference }} |
{{ $payment->metadata['plan_name'] ?? $payment->plan?->name ?? '-' }} |
{{ ucfirst($payment->billing_cycle) }} |
@if($isComp)
Complimentary
@else
{{ $currency }}{{ number_format($payment->amount, 2) }}
@endif
|
{{ $isComp ? 'Admin' : ucfirst($payment->gateway) }} |
@if($payment->status === 'completed')
@elseif($payment->status === 'pending')
@else
@endif
{{ ucfirst($payment->status) }}
|
@if($payment->status === 'completed')
Download
@else
—
@endif
|
@endforeach
@else
No billing history yet. Subscribe to a plan to see your invoices here.
@endif
@endsection
@push('scripts')
@endpush