@extends('front.layouts.app-auth') @section('content') @php $isSponsor = $sponsorship->sponsor_user_id === $user->id; $isBeneficiary = $sponsorship->beneficiary_user_id === $user->id; // Determine display status - check for expired first $isExpired = false; if ($sponsorship->status === 'pending' && $sponsorship->offer_expire_in) { $expireDate = is_string($sponsorship->offer_expire_in) ? \Carbon\Carbon::parse($sponsorship->offer_expire_in) : $sponsorship->offer_expire_in; $isExpired = $expireDate->isPast(); } $displayStatus = ($sponsorship->is_withdrawal == 1) ? 'withdrawn' : ($isExpired ? 'expired' : ($sponsorship->status ?? 'pending')); // Generate avatar initials if ($isSponsor) { $profileUser = $sponsorship->beneficiary; $profileName = $profileUser ? $profileUser->full_name : 'Unknown'; } else { $profileUser = $sponsorship->sponsor; $profileName = $profileUser ? $profileUser->full_name : 'Unknown'; } $initials = collect(explode(' ', $profileName))->map(function($word) { return strtoupper(substr($word, 0, 1)); })->take(2)->join(''); $colors = ['#3b82f6', '#8b5cf6', '#10b981', '#f59e0b', '#ef4444', '#ec4899']; $avatarColor = $colors[($sponsorship->id % 6)]; // Format offer type $offerTypeMap = [ 1 => 'Endorsement Deal', 2 => 'Brand Ambassador', 3 => 'Team Partnership', 4 => 'Product Sponsorship', 5 => 'Event Sponsor', 6 => 'Media Partnership', ]; $offerTypeSubtitle = 'Partnership'; if ($sponsorship->offer_type && isset($offerTypeMap[$sponsorship->offer_type])) { $offerTypeSubtitle = $offerTypeMap[$sponsorship->offer_type]; } // Format duration $durationMonths = $sponsorship->duration ?? 12; $duration = $durationMonths . ' months'; // Calculate payment progress $totalCommitted = $sponsorship->funding_amount; $totalPaid = $sponsorship->installments() ->whereIn('payment_status', [\App\Models\Users\SponsorshipInstallment::STATUS_PAID, \App\Models\Users\SponsorshipInstallment::STATUS_APPROVED_AND_RELEASED]) ->sum('installment_amount'); $totalAuthorized = 0; // Authorized payments (if any evidence submitted but not paid) $completedMilestones = $sponsorship->installments() ->whereIn('payment_status', [\App\Models\Users\SponsorshipInstallment::STATUS_PAID, \App\Models\Users\SponsorshipInstallment::STATUS_APPROVED_AND_RELEASED]) ->count(); $totalMilestones = $sponsorship->installments()->count() ?: 1; $progressPercentage = $totalCommitted > 0 ? ($totalPaid / $totalCommitted) * 100 : 0; @endphp
{{ $sponsorship->notes }}
Messages