@extends('layouts.school') @section('title', 'Subscription & Billing') @section('header', 'Subscription & Billing') @section('content') @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif
{{-- Current subscription --}}

Current subscription

@if($currentSubscription)

Plan

{{ $currentSubscription->plan?->name ?? '—' }}

Status

{{ ucfirst($currentSubscription->status->value) }}

Starts

{{ optional($currentSubscription->starts_at)->toDateString() }}

Ends / renews

{{ optional($currentSubscription->ends_at)->toDateString() }}

@if($currentSubscription->payment_amount)

Last paid

₦{{ number_format((float) $currentSubscription->payment_amount, 2) }}

@endif @if($currentSubscription->ends_at) @php $days = (int) now()->diffInDays($currentSubscription->ends_at, false); @endphp

Days remaining

@if($days < 0) Expired {{ abs($days) }}d ago @elseif($days === 0) Due today @else {{ $days }} days @endif

@endif
@if($currentSubscription->plan?->features)
@foreach($currentSubscription->plan->features as $feature) {{ ucwords(str_replace('_', ' ', $feature)) }} @endforeach
@endif @else

No active subscription yet — choose a plan below to get started.

@endif
{{-- Unpaid quotes --}} @if($issuedInvoices->isNotEmpty())

Outstanding invoices

@foreach($issuedInvoices as $invoice)

{{ $invoice->invoice_ref }}

{{ $invoice->subscription?->plan?->name ?? 'Subscription' }} · {{ number_format($invoice->total, 2) }} {{ $invoice->currency }}

@csrf ₦{{ number_format($invoice->total, 2) }}
@endforeach
@endif {{-- Billing history --}} @if($billingHistory->isNotEmpty())

Billing history

@foreach($billingHistory as $invoice)

{{ $invoice->invoice_ref }}

{{ $invoice->subscription?->plan?->name ?? 'Subscription' }} · {{ optional($invoice->period_start)->format('d M Y') }} → {{ optional($invoice->period_end)->format('d M Y') }}

₦{{ number_format((float) $invoice->total, 2) }}

{{ ucfirst($invoice->status) }}
@endforeach
@endif {{-- Plan catalogue with live quotes --}}

Available plans

@foreach($plans as $plan) @php $quote = $quotes[$plan->id] ?? null; @endphp

{{ $plan->name }}

{{ $plan->description }}

@if($plan->billingType() === 'trial') Free @elseif($plan->billingType() === 'per_student') ₦{{ number_format((float) ($plan->per_student_price ?? 0), 0) }}/student @else ₦{{ number_format($plan->price, 0) }}/month @endif

@if($quote)

Quote today: ₦{{ number_format($quote['total'], 2) }}

{{ $quote['period_start'] }} – {{ $quote['period_end'] }}

@endif
@csrf
@endforeach

Prices are snapshot when you pay. Per-student plans bill the number of active students at that time.

{{-- Usage --}}

Plan limits

@if($school->plan) @php $limits = [ 'Students' => ['used' => $usage['students'], 'max' => $school->plan->max_students], 'Teachers' => ['used' => $usage['teachers'], 'max' => $school->plan->max_teachers], 'Classes' => ['used' => $usage['classes'], 'max' => $school->plan->max_classes], ]; @endphp
    @foreach($limits as $label => $row)
  • {{ $label }} {{ $row['used'] }} / {{ $row['max'] ?? '∞' }}
  • @endforeach

Usage counts your active student, teacher and class records.

@else

No plan assigned.

@endif
@endsection