@php $subscription = $type === 'shared' ? $item : $item->sharedSubscription; $service = $subscription?->service; $serviceName = $service?->name ?? 'Subscription'; $planName = $subscription?->servicePlan?->name ?? 'Plan'; $cardTitle = trim($serviceName . ' ' . $planName); $ownerName = $subscription?->owner?->name ?? 'Unknown owner'; $logo = $service?->logo ? asset($service->logo) : null; $initial = strtoupper(substr(trim((string) $serviceName), 0, 1)) ?: 'S'; $avatarInitial = strtoupper(substr(trim((string) ($type === 'shared' ? $ownerName : ($item->user?->name ?? $ownerName))), 0, 1)) ?: 'S'; $statusValue = (string) ($type === 'shared' ? $item->status : $item->status); $isExpired = in_array($statusValue, ['expired', 'cancelled'], true) || ($type === 'shared' && $item->ends_at && $item->ends_at->isPast()) || ($type === 'subscribed' && $item->expires_at && $item->expires_at->isPast()) || ($type === 'subscribed' && $subscription && in_array((string) $subscription->status, ['expired', 'cancelled'], true)) || ($type === 'subscribed' && $subscription && $subscription->ends_at && $subscription->ends_at->isPast()); $currency = strtoupper((string) ($subscription?->servicePlan?->currency ?? 'USD')); $currencySymbol = [ 'USD' => '$', 'EUR' => '€', 'GBP' => '£', ][$currency] ?? '$'; $priceValue = (float) ($type === 'shared' ? $item->price_per_slot : $item->subscription_amount); $noteLabel = $isExpired ? 'Subscription sharing canceled' : ($type === 'shared' ? ($item->is_public ? 'Subscription is public' : 'Subscription is hidden') : ($item->payment_verified ? 'Payment verified' : 'Payment pending')); $slotTotal = $type === 'shared' ? max((int) $item->total_slots, 1) : max((int) ($subscription?->total_slots ?? $item->slots_taken), max((int) $item->slots_taken, 1)); $slotFilled = $type === 'shared' ? min(max((int) ($item->active_members_count ?? 0), 0), $slotTotal) : min(max((int) $item->slots_taken, 0), $slotTotal); $progressSegments = 6; $filledSegments = (int) round(($slotFilled / max($slotTotal, 1)) * $progressSegments); $filledSegments = max(0, min($filledSegments, $progressSegments)); $metricLabel = $type === 'shared' ? 'Co-subscribers' : 'Your seats'; $openUrl = $subscription ? route('subscriptions.manage', $subscription) : route('subscriptions.index'); @endphp

{{ $cardTitle }}

@if($isExpired) Expired @endif
{{ $currencySymbol }}{{ number_format($priceValue, 2) }} / month
{{ $noteLabel }}
{{ $slotFilled }}/{{ $slotTotal }} {{ $metricLabel }}
{{ $avatarInitial }}
Manage subscription @if($type === 'shared') @if($isSuperAdmin && auth()->user()->can('update subscription'))
Manage @if(! $isExpired && auth()->user()->can('delete subscription'))
@csrf @method('DELETE')
@endif
@endif @else @if(! $isExpired && (auth()->user()->can('update subscription member status') || auth()->user()->can('delete subscription')))
@can('update subscription member status') Edit @endcan @can('delete subscription')
@csrf @method('DELETE')
@endcan
@endif @endif