@extends('admin._layout') @section('title', 'باقات الاشتراك') @push('head') @endpush @section('content') @if($plans->isEmpty())

لا توجد باقات بعد

ابدأ بإنشاء باقتك الأولى — تجربة، أساسي، احترافي…

@else
@foreach($plans as $p) @php $catalog = \App\Support\PlanFeature::catalog(); $coreKeys = \App\Support\PlanFeature::coreKeys(); $features = is_array($p->features) ? $p->features : []; // Visible feature list = core (always shown) + plan extras. $visibleFeatures = array_values(array_unique(array_merge($coreKeys, $features))); // Highlight ribbon: most-subscribed plan gets "الأكثر طلباً". $isMostPopular = $p->active_subscriptions_count > 0 && $p->active_subscriptions_count === $plans->max('active_subscriptions_count'); @endphp
@if($isMostPopular && $p->is_active)
الأكثر اشتراكاً
@elseif(! $p->is_active)
متوقفة
@endif
{{ $p->name }}
{{ $p->slug }}
@php $pricesMap = is_array($p->prices) ? $p->prices : []; // Fallback to the legacy single-price column so // pre-multi-currency plans still render something. if (empty($pricesMap) && $p->price > 0) { $pricesMap = [$p->currency => (float) $p->price]; } $baseCode = $p->currency ?: array_key_first($pricesMap); $basePrice = $pricesMap[$baseCode] ?? ($p->price ?? 0); @endphp
{{ number_format($basePrice, 0) }} {!! \App\Support\Currency::symbol($baseCode) !!} / {{ $p->duration_days }} يوم
@if(count($pricesMap) > 1)
@foreach($pricesMap as $code => $amt) @if($code === $baseCode) @continue @endif {{ number_format($amt, 0) }} {!! \App\Support\Currency::symbol($code) !!} @endforeach
@endif
أطباء {{ $p->max_doctors ?? 'غير محدود' }}
مرضى {{ $p->max_patients ? number_format($p->max_patients) : 'غير محدود' }}
تخزين @if($p->max_storage_mb) {{ $p->max_storage_mb >= 1024 ? round($p->max_storage_mb / 1024, 1) . ' GB' : $p->max_storage_mb . ' MB' }} @else غير محدود @endif
@if(! empty($visibleFeatures))
    @foreach($visibleFeatures as $f) @php $meta = $catalog[$f] ?? null; @endphp @if($meta)
  • {{ $meta['label'] }} @if(in_array($f, $coreKeys, true)) أساسي @endif
  • @endif @endforeach
@endif
{{ $p->active_subscriptions_count }} / {{ $p->subscriptions_count }} اشتراك إجمالي
@if($p->active_subscriptions_count > 0) عرض @else لا يوجد مشتركين @endif
@php // Plan payload for the edit modal — emitted as a single // JSON attribute so we don't have to escape inside onclick. $planPayload = json_encode([ 'id' => $p->id, 'name' => $p->name, 'slug' => $p->slug, 'price' => (float) $p->price, 'currency' => $p->currency, 'prices' => $pricesMap, 'duration_days' => $p->duration_days, 'max_doctors' => $p->max_doctors, 'max_patients' => $p->max_patients, 'max_storage_mb' => $p->max_storage_mb, 'features' => $features, 'is_active' => (bool) $p->is_active, 'sort_order' => $p->sort_order, ], JSON_UNESCAPED_UNICODE | JSON_HEX_APOS | JSON_HEX_QUOT); @endphp
@endforeach
@endif {{-- ============================================================ --}} {{-- Plan create / edit modal --}} {{-- ============================================================ --}} @endsection @push('scripts') @endpush