@php
$plan = $invitation->plan ?? null;
$showShareButton = $plan ? (bool) ($plan->enable_share ?? true) : true;
// Calcular el precio base (lista) del plan actual según el país
$currentPlanPriceRow = $plan ? $plan->prices()->first() : null;
$currentPlanBasePrice = $currentPlanPriceRow ? (float) $currentPlanPriceRow->price : 0.0;
// Determinar si el plan actual es pago para reglas de upgrade (para el monto mostrado)
$isPaidPlanForPricing = $plan && strtolower((string) $plan->name) !== 'free';
// Construir lista de planes superiores por jerarquía (level) al actual, visibles
// Solo mostrar planes para clientes finales (is_business = false o null)
$allVisiblePlans = \App\Models\Plan::where('is_visible', true)
->where(function($q) {
$q->where('is_business', false)
->orWhereNull('is_business');
})
->get();
$currentLevel = $plan ? (int)($plan->level ?? 0) : 0;
$upgradePlans = $allVisiblePlans
->filter(function($p) use ($plan, $currentLevel) {
// Excluir el plan actual
if ($plan && $p->id === $plan->id) return false;
// Considerar superior si su nivel es mayor al nivel actual
return (int)($p->level ?? 0) > $currentLevel;
})
// Ordenar por jerarquía ascendente (de inferior a superior); empate por precio ascendente
->sortBy(function($p){
$lvl = (int)($p->level ?? PHP_INT_MAX);
$row = $p->prices()->first();
$price = $row ? (float) $row->price : PHP_INT_MAX;
return sprintf('%08d-%015.2f', $lvl, $price);
})
->values();
$upgradePlanFeatures = collect();
if ($upgradePlans->isNotEmpty()) {
$upgradePlanFeatures = \App\Models\PlanFeature::query()
->whereIn('plan_id', $upgradePlans->pluck('id'))
->active()
->forInvitationType($invitation->invitation_type_id)
->ordered()
->get()
->groupBy('plan_id');
}
@endphp
Comparte tu invitación con todos.
Es el momento perfecto para compartirla
y comenzar a difundir la emoción de
tu próximo evento.