@extends('layouts.portal') @section('title', 'Agent Dashboard') @section('page_title', 'Agent Portal') @section('page_subtitle', 'Your Referral & Earnings Hub') @section('sidebar') @include('agent.partials.sidebar', ['active' => 'dashboard']) @endsection @section('content')
Agent Level

Welcome back, {{ auth()->user()->name }}!

Your earnings are growing. Keep referring!

Total Earnings

RM{{ number_format($stats['commission_earned'] ?? 0, 2) }}

Lifetime Commission

@if(!empty($upline))

⬆️ Your Upline

@foreach($upline as $uplineMember)
{{ substr($uplineMember['agent']->name, 0, 1) }}

{{ $uplineMember['agent']->name }}

{{ $uplineMember['agent']->email }}

Level {{ $uplineMember['level'] }} Upline

@endforeach
@endif
@if($pendingAgents->count() > 0)

🔔 Pending Agent Approvals

@foreach($pendingAgents as $pendingAgent)
{{ substr($pendingAgent->name, 0, 1) }}

{{ $pendingAgent->name }}

{{ $pendingAgent->email }}

Waiting for your approval

@csrf
@csrf
@endforeach
@endif @if(isset($approvedAgents) && $approvedAgents->count() > 0)

✅ Your Referred Agents

@foreach($approvedAgents as $approvedAgent)
{{ substr($approvedAgent->name, 0, 1) }}

{{ $approvedAgent->name }}

{{ $approvedAgent->email }}

Level {{ $approvedAgent->getMlmLevel() }} • {{ $approvedAgent->clients()->count() }} clients

Active

@endforeach
@endif @if(!empty($downline))

⬇️ Your Downline Team

@foreach($downline as $member)
{{ substr($member['agent']->name, 0, 1) }}

{{ $member['agent']->name }}

{{ $member['agent']->email }}

Level {{ $member['level'] }} Agent • {{ $member['clients_count'] }} clients

RM{{ number_format($member['commission_earned'], 2) }}

{{ $member['wills_count'] }} wills

@endforeach
@endif
This Month

Total Earnings

RM{{ number_format($stats['commission_earned'] ?? 0, 2) }}

Active

Active Referrals

{{ $stats['total_referrals'] ?? 0 }}

New

This Month

{{ $stats['this_month'] ?? 0 }}

Pending

Pending Payout

$0.00

🔗

Referral Link

Share to earn

{{ url('/agent/register?ref=' . auth()->user()->referral_code) }}

👤

Add Client

New referral

Create Client →
🌳

My Network

View genealogy

View Tree →
📊

Reports

View analytics

View Reports →
👥

My Referrals

Track clients

View All →
💰

Commission

View earnings

See Details →

Recent Referrals

View All
@if($referredClients->count() > 0)
@foreach($referredClients as $client) @endforeach
Client Name Email Phone Status Date Action
{{ substr($client->first_name, 0, 1) }}

{{ $client->first_name }} {{ $client->last_name }}

{{ $client->email }} {{ $client->phone }} @if($client->status == 'active') Active @elseif($client->status == 'pending') Pending @elseif($client->status == 'pending_approval') Pending Approval @else {{ ucfirst(str_replace('_', ' ', $client->status ?? 'Unknown')) }} @endif {{ $client->created_at->format('M d, Y') }} View Details
{{ $referredClients->links() }}
@else

No Referrals Yet

Start referring clients and earn commissions!

Add First Referral
@endif
@endsection