@php use App\Enums\BillingCycle; use App\Models\SubscriptionPlan; $locale = $locale ?? app()->getLocale(); $eyebrow = $data['eyebrow'][$locale] ?? $data['subheading'][$locale] ?? __('Membership Tiers'); $heading = $data['heading'][$locale] ?? __('Choose Your __Caliber.__'); $description = $data['description'][$locale] ?? ''; $renderedHeading = preg_replace_callback('/__(.+?)__/u', function ($m) { return ''.e($m[1]).''; }, e($heading)); $plans = SubscriptionPlan::query()->where('status', true)->orderBy('sort_order')->with(['features','prices'])->get(); $featured = $plans->firstWhere('is_featured', true); $others = $plans->where('is_featured', false)->values(); if ($featured && $others->count() >= 2) { $ordered = [$others[0], $featured, $others[1]]; } elseif ($featured && $others->count() === 1) { $ordered = [$others[0], $featured]; } else { $ordered = $plans->all(); } $allPrices = $plans->flatMap->prices; $maxHalfYearlyDiscount = $allPrices->where('billing_cycle', BillingCycle::HalfYearly)->max('discount'); $maxYearlyDiscount = $allPrices->where('billing_cycle', BillingCycle::Yearly)->max('discount'); $currencyCode = siteCurrency('code'); @endphp
{{ $eyebrow }}

{!! $renderedHeading !!}

@if($description)

{!! nl2br(e($description)) !!}

@endif
@foreach($ordered as $plan) @php $isFeatured = $plan->is_featured; $prices = $plan->prices->keyBy(fn($p) => $p->billing_cycle instanceof BillingCycle ? $p->billing_cycle->value : (string) $p->billing_cycle); $monthlyAmt = (float) (($prices['monthly'] ?? null)?->price ?? 0); $planIcon = match(true) { $monthlyAmt <= 0 => 'fa-solid fa-seedling', $isFeatured => 'fa-solid fa-crown', default => 'fa-solid fa-gem', }; if ($monthlyAmt <= 0) { $badgeText = $plan->plan_badge ?: __('Free Forever'); } elseif ($isFeatured) { $badgeText = $plan->plan_badge ?: __('Most Popular'); } else { $badgeText = $plan->plan_badge; } @endphp
@if($isFeatured && $badgeText) {{ $badgeText }} @endif

{{ $plan->name }}

{{ $plan->description ?: __('Access to core platform features.') }}

{{ $currencyCode }} {{ number_format($monthlyAmt, 0, '.', '') }} /{{ __('mo') }}
{{ __('Billed monthly') }}
{{ $plan->trial_days > 0 ? __('Start :d-Day Free Trial', ['d' => $plan->trial_days]) : __('Begin Application') }}
{{ __("What's Included") }}
    @foreach($plan->features as $feature)
  • {{ $feature->feature_label }} @if(!$feature->isToggle()) {{ $feature->isUnlimited() ? __('Unlimited') : $feature->feature_value }} @endif
  • @endforeach
@endforeach