@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 = marketplaceImageUrl($service?->logo ?: $service?->category?->image_url); $initial = strtoupper(substr(trim((string) $serviceName), 0, 1)) ?: 'S'; $cardUser = $type === 'shared' ? $subscription?->owner : ($item->user ?? $subscription?->owner); $avatarInitial = strtoupper(substr(trim((string) ($cardUser?->name ?? $ownerName)), 0, 1)) ?: 'S'; $cardUserAvatar = str_replace('\\', '/', trim((string) ($cardUser?->avatar ?? ''))); $cardUserAvatarSrc = ''; if ($cardUserAvatar !== '') { if (preg_match('/^https?:\/\//i', $cardUserAvatar)) { $cardUserAvatarSrc = $cardUserAvatar; } elseif (file_exists(public_path(ltrim($cardUserAvatar, '/')))) { $cardUserAvatarSrc = asset(ltrim($cardUserAvatar, '/')); } elseif (file_exists(public_path('assets/img/avatars/users/' . basename($cardUserAvatar)))) { $cardUserAvatarSrc = asset('assets/img/avatars/users/' . basename($cardUserAvatar)); } else { $cardUserAvatarSrc = asset(ltrim($cardUserAvatar, '/')); } } elseif (file_exists(public_path('assets/img/avatars/user_avatar.webp'))) { $cardUserAvatarSrc = asset('assets/img/avatars/user_avatar.webp'); } $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(max((int) $item->total_slots - (int) ($item->available_slots ?? ($item->total_slots - 1)), (int) ($item->active_members_count ?? 0) + 1), 1), $slotTotal) : min(max((int) $item->slots_taken, 0), $slotTotal); $progressSegments = max($slotTotal, 1); $filledSegments = min(max((int) $slotFilled, 0), $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 }}
@if($cardUserAvatarSrc !== '') {{ $cardUser?->name ?? 'User' }} @endif {{ $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