@extends('layouts.membership') @section('title', 'Dashboard - The LaLiT Loyalty') @section('content')
@php $extraData = isset($membershipUser['extra_data']) ? (is_string($membershipUser['extra_data']) ? json_decode($membershipUser['extra_data'], true) : $membershipUser['extra_data']) : []; $extraData = is_array($extraData) ? $extraData : []; $salutation = $extraData['salutation'] ?? ''; // Capitalize salutation properly (MR -> Mr, MS -> Ms, etc.) $salutation = $salutation ? ucfirst(strtolower($salutation)) : ''; // Capitalize name properly $name = $membershipUser['name'] ?? 'Member'; $name = ucwords(strtolower($name)); $tierEndDateRaw = null; if (!empty($extraData['tier_data']) && is_array($extraData['tier_data']) && !empty($extraData['tier_data'][0]['tier_end_date'])) { $tierEndDateRaw = $extraData['tier_data'][0]['tier_end_date']; } elseif (isset($membershipUser['tier_data']) && is_array($membershipUser['tier_data']) && !empty($membershipUser['tier_data'][0]['tier_end_date'])) { $tierEndDateRaw = $membershipUser['tier_data'][0]['tier_end_date']; } elseif (isset($memberData['extra_data']['tier_data'][0]['tier_end_date'])) { $tierEndDateRaw = $memberData['extra_data']['tier_data'][0]['tier_end_date']; } $tierEndDateFormatted = null; if ($tierEndDateRaw && is_string($tierEndDateRaw)) { try { $tierEndDateFormatted = \Carbon\Carbon::parse($tierEndDateRaw)->format('d M Y'); } catch (\Throwable $e) { $tierEndDateFormatted = null; } } @endphp

Welcome to The LaLiT Loyalty, {{ $salutation ? $salutation . ' ' : '' }}{{ $name }}

Membership Number {{ $membershipUser['membership_number'] ?? '2007513951' }}@if($tierEndDateFormatted) (Tier End Date: {{ $tierEndDateFormatted }})@endif
The LaLiT Loyalty Points Balance

{{ $totalPoints ?? '0' }}

Available The LaLiT Loyalty Balance

REDEEM POINTS
Tier Status
@php // Define tier order and colors $tiers = [ 'BLUE' => ['color' => '#4169E1', 'order' => 1], 'SILVER' => ['color' => '#c0c0c0', 'order' => 2], 'GOLD' => ['color' => '#d4af37', 'order' => 3], 'PLATINUM' => ['color' => '#708090', 'order' => 4] ]; // Get current member tier from tier_data or fallback to tier column $currentTier = 'BLUE'; // default $tierStartDate = null; $tierEndDate = null; if (isset($membershipUser['tier_data']) && is_array($membershipUser['tier_data']) && !empty($membershipUser['tier_data'])) { $currentTierData = $membershipUser['tier_data'][0] ?? []; $currentTier = $currentTierData['tier_code_id'] ?? $membershipUser['tier'] ?? 'BLUE'; $tierStartDate = $currentTierData['tier_start_date'] ?? null; $tierEndDate = $currentTierData['tier_end_date'] ?? null; } else { $currentTier = $membershipUser['tier'] ?? 'BLUE'; } $currentTierOrder = $tiers[strtoupper($currentTier)]['order'] ?? 1; $currentTierColor = $tiers[strtoupper($currentTier)]['color'] ?? '#4169E1'; @endphp
@foreach($tiers as $tierName => $tierInfo) @php $isActive = $tierInfo['order'] <= $currentTierOrder; $isCurrent = strtoupper($currentTier) === $tierName; @endphp
@if($isCurrent) @elseif($isActive) @endif
{{ $tierName }}
@endforeach
@php // Calculate tier progress message $progressMessage = "Spend an additional INR 2,500 to collect 5,000 Tier Points to become a Silver member"; if (strtoupper($currentTier) === 'SILVER') { $progressMessage = "Spend an additional INR 5,000 to collect 10,000 Tier Points to become a Gold member"; } elseif (strtoupper($currentTier) === 'GOLD') { $progressMessage = "Spend an additional INR 10,000 to collect 20,000 Tier Points to become a Platinum member"; } elseif (strtoupper($currentTier) === 'PLATINUM') { $progressMessage = "Congratulations! You have achieved the highest tier status."; } @endphp

Current Tier: {{ strtoupper($currentTier) }} @if($tierEndDate)
Valid until {{ date('M d, Y', strtotime($tierEndDate)) }} @endif

MEMBER BENEFITS
@php // Get current tier and determine card image $currentTierCode = strtolower($currentTier ?? 'blue'); $cardImage = 'blue-card.png'; // default // Map tier to card image $tierImages = [ 'blue' => 'blue-card.png', 'silver' => 'silver-card.png', 'gold' => 'gold-card.png', 'platinum' => 'platinum-card.png' ]; if (isset($tierImages[$currentTierCode])) { $cardImage = $tierImages[$currentTierCode]; } @endphp
{{ ucfirst($currentTierCode) }} Membership Card
{{ $membershipUser['membership_number'] ?? '2007513951' }}
YOUR E-CARD

MY STAYS

@if(isset($staysError) && $staysError) @endif
@if(empty($upcomingStays))
No upcoming stays found.
@else
@foreach($upcomingStays as $stay)
{{ $stay['hotelName'] ?? 'The LaLiT Hotel' }}
Reservation No: {{ $stay['reservationNumber'] ?? 'N/A' }}
@php $status = strtoupper($stay['bookingStatus'] ?? 'CONFIRMED'); $badgeClass = 'bg-success'; if ($status === 'CANCELLED') $badgeClass = 'bg-danger'; elseif ($status === 'PENDING') $badgeClass = 'bg-warning text-dark'; @endphp {{ $status }}
CHECK-IN {{ isset($stay['checkIn']) ? date('d M Y', strtotime($stay['checkIn'])) : 'N/A' }}
CHECK-OUT {{ isset($stay['checkOut']) ? date('d M Y', strtotime($stay['checkOut'])) : 'N/A' }}
Room Type {{ $stay['roomType'] ?? ($stay['rooms'][0]['roomName'] ?? 'Executive Room') }}
Total Amount {{ isset($stay['totalAmountSpent']) && is_numeric($stay['totalAmountSpent']) ? '₹' . number_format($stay['totalAmountSpent'], 2) : 'N/A' }}
Special Requests: {{ !empty($stay['specialRequests']) ? $stay['specialRequests'] : 'No special requests' }}
@endforeach
@endif
@endsection