@extends('backend.layouts.app') @section('content')

Refer & Earn

{{-- Stats --}}
๐Ÿ‘ฅ Total Referrers
{{ $totalReferrers }}
๐Ÿ”— Joined via Referral
{{ $totalJoined }}
โญ Total Points Given
{{ number_format($totalPointsGiven) }}
๐Ÿ”ฅ Today's Referrals
{{ $todayReferrals }}
๐Ÿ“ต Not Installed
{{ $totalNotInstalled }}
{{-- Top 3 (only on referrers tab) --}} @if($tab == 'referrers' && $top3->count())
@foreach($top3 as $i => $top)
{{ ['๐Ÿฅ‡','๐Ÿฅˆ','๐Ÿฅ‰'][$i] }}
{{ $top->referral_user->name ?? 'N/A' }}
{{ $top->referral_user->phone ?? '' }}
โœ… {{ $top->ref_count }} referrals ยท โญ {{ $top->pts }} pts
@endforeach
@endif
{{-- Tabs --}} {{-- Filters --}}
@if($search || $dateFilter) โœ• Clear @endif
@if($tab == 'referrers') {{-- REFERRERS TABLE --}} @forelse($userReferralData as $key => $value) @php $u = $value->referral_user; $stats = $successCounts[$value->user_id] ?? null; $count = $stats->count ?? 0; $isToday = \Carbon\Carbon::parse($value->created_at)->isToday(); @endphp @empty @endforelse
# User Phone Referral Code Reward Points Successful Referrals Action
{{ ($userReferralData->currentPage()-1)*$userReferralData->perPage() + $key + 1 }}
{{ strtoupper(substr($u->name ?? 'U', 0, 1)) }}
{{ $u->name ?? 'N/A' }} @if($isToday)NEW@endif
#{{ $u->id ?? '' }} ยท {{ $u->email ?? '' }}
{{ $u->phone ?? 'โ€”' }} {{ $value->referral_code }} โญ {{ $u->reward_points ?? 0 }} pts โœ… {{ $count }} users @can('view_inquiry') ๐Ÿ‘ View @endcan

No referrers found

@elseif($tab == 'not_installed') {{-- NOT INSTALLED TABLE --}} @forelse($userReferralData as $key => $value) @empty @endforelse
# Person Phone Referred By Invite Date Days Ago Action
{{ ($userReferralData->currentPage()-1)*$userReferralData->perPage() + $key + 1 }}
{{ strtoupper(substr($value->name ?? 'U', 0, 1)) }}
{{ $value->name ?? 'N/A' }}
{{ $value->email ?? '' }}
{{ $value->phone ?? 'โ€”' }}
{{ $value->referred_by_name ?? 'โ€”' }}
{{ $value->referred_by_phone ?? '' }}
{{ $value->referral_code }}
{{ \Carbon\Carbon::parse($value->created_at)->format('d M Y') }}
{{ \Carbon\Carbon::parse($value->created_at)->format('h:i A') }}
{{ $value->days_ago }} days @if($value->phone) @php $phone = preg_replace('/\D/', '', $value->phone); $msg = urlencode("Hi {$value->name}! ๐Ÿ‘‹ You were invited to BestMart by {$value->referred_by_name}.\n\nDownload & signup with referral code: *{$value->referral_code}*\nGet 51 Reward Points instantly! ๐ŸŽ\n\nhttps://bestmart.in/api/s/{$value->referral_code}"); @endphp ๐Ÿ’ฌ Resend @else No phone @endif

๐ŸŽ‰ Everyone installed the app!

@elseif($tab == 'invite_all') {{-- INVITE ALL TAB --}} @php $bulkInvites = \Illuminate\Support\Facades\DB::table('bulk_invites') ->join('users as u', 'u.id', '=', 'bulk_invites.user_id') ->select('bulk_invites.*', 'u.name as inviter_name', 'u.phone as inviter_phone') ->orderByDesc('bulk_invites.invited_at') ->paginate(20); $bulkTotal = \Illuminate\Support\Facades\DB::table('bulk_invites')->count(); $bulkPending = \Illuminate\Support\Facades\DB::table('bulk_invites')->where('status','pending')->count(); $bulkInstalled = \Illuminate\Support\Facades\DB::table('bulk_invites')->where('status','installed')->count(); @endphp
๐Ÿ“ฑ Invite All Records โณ {{ $bulkPending }} Pending โœ… {{ $bulkInstalled }} Installed Total: {{ $bulkTotal }}
@forelse($bulkInvites as $key => $bi) @empty @endforelse
# Contact Phone Invited By Date Status Action
{{ ($bulkInvites->currentPage()-1)*$bulkInvites->perPage() + $key + 1 }} {{ $bi->contact_name ?: 'โ€”' }} {{ $bi->contact_phone }}
{{ $bi->inviter_name }}
{{ $bi->inviter_phone }}
{{ $bi->referral_code }}
{{ \Carbon\Carbon::parse($bi->invited_at)->format('d M Y') }}
{{ \Carbon\Carbon::parse($bi->invited_at)->format('h:i A') }}
@if($bi->status == 'installed') โœ… Installed @else โณ Pending @endif @php $ph = preg_replace('/\D/', '', $bi->contact_phone); $msg = urlencode("Hi {$bi->contact_name}! ๐Ÿ‘‹ You were invited to BestMart!\n\nSignup with code: *{$bi->referral_code}*\nGet 51 Reward Points! ๐ŸŽ\nhttps://bestmart.in/api/s/{$bi->referral_code}"); @endphp ๐Ÿ’ฌ Resend
No invite records found
{{ $bulkInvites->appends(request()->query())->links() }}
@else {{-- JOINED VIA REFERRAL TABLE --}} @forelse($userReferralData as $key => $value) @php $isToday = \Carbon\Carbon::parse($value->created_at)->isToday(); @endphp @empty @endforelse
# Joined Person Phone Reward Points Referred By Joined Date
{{ ($userReferralData->currentPage()-1)*$userReferralData->perPage() + $key + 1 }}
{{ strtoupper(substr($value->name ?? 'U', 0, 1)) }}
{{ $value->name ?? 'N/A' }} @if($isToday)TODAY@endif
#{{ $value->id }} ยท {{ $value->email ?? '' }}
{{ $value->phone ?? 'โ€”' }} โญ {{ $value->reward_points }} pts
{{ $value->referred_by_name ?? 'โ€”' }}
{{ $value->referred_by_phone ?? '' }}
{{ $value->referral_code }}
{{ \Carbon\Carbon::parse($value->created_at)->format('d M Y') }}
{{ \Carbon\Carbon::parse($value->created_at)->format('h:i A') }}

No joined users found

@endif
@if($tab != 'invite_all')
{{ $userReferralData->appends(request()->query())->links() }}
@endif
@endsection