@extends('appshell::layouts.private') @section('title') Affiliate: {{ $affiliate->code }} @stop @section('content') @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- ── Header card ──────────────────────────────────── --}}

{{ $affiliate->code }} @php $badgeClass = match($affiliate->status) { 'active' => 'badge-success', 'pending' => 'badge-warning', 'suspended' => 'badge-danger', default => 'badge-secondary', }; @endphp {{ ucfirst($affiliate->status) }}

{{ optional($affiliate->user)->email ?? '(no user)' }}

Commission: {{ ucfirst($affiliate->commission_type) }} @if($affiliate->commission_type === 'percent') {{ $affiliate->commission_value }}% @else ${{ number_format($affiliate->commission_value, 2) }} flat @endif

Member since: {{ $affiliate->created_at->format('d M Y') }}

{{-- Actions --}}
@if($affiliate->status !== 'active')
@csrf
@endif @if($affiliate->status !== 'suspended')
@csrf
@endif
@csrf
← Back
@if($affiliate->payout_instructions)
Payment Details (affiliate-supplied)
{{ $affiliate->payout_instructions }}
@endif
{{-- ── Tabs ─────────────────────────────────────────── --}}
{{-- Conversions tab --}}
@forelse($affiliate->conversions as $conversion) @php $convBadge = match($conversion->status) { 'approved' => 'badge-success', 'pending' => 'badge-warning', 'rejected' => 'badge-danger', 'paid' => 'badge-primary', default => 'badge-secondary', }; @endphp @php $convUser = $conversion->user ?? optional($conversion->order)->user; $convEmail = optional($convUser)->email ?? optional(optional($conversion->order)->billpayer)->getEmail() ?? null; @endphp @empty @endforelse
Recruit Email Status Joined Order Tier Amount Commission Actions
@if($convUser) {{ $convUser->name ?? $convUser->email }} @else @endif {{ $convEmail ?? '—' }} {{ ucfirst($conversion->status) }} {{ $conversion->created_at->format('d M Y') }} @if($conversion->order) {{ $conversion->order->number }} @else @endif Tier {{ $conversion->tier ?? 1 }} ${{ number_format($conversion->amount, 2) }} ${{ number_format($conversion->commission, 2) }} @if($conversion->status === 'pending')
@csrf
@csrf
@else @endif
📊 Conversions tab — no conversions recorded for this affiliate yet.
Total Commission: ${{ number_format($affiliate->conversions->sum('commission'), 2) }}
{{-- Clicks tab --}}
@forelse($affiliate->clicks as $click) @empty @endforelse
# IP Landing URL Referrer Converted Date
{{ $click->id }} {{ $click->ip }} {{ $click->landing_url }} {{ $click->referrer ?? '—' }} @if($click->converted_at) Yes @else No @endif {{ $click->created_at->format('d M Y H:i') }}
🖱️ Clicks tab — no click tracking data for this affiliate yet.
{{-- Payouts tab --}}
@forelse($affiliate->payouts as $payout) @empty @endforelse
# Amount Status Reference Paid At Actions
{{ $payout->id }} ${{ number_format($payout->amount, 2) }} {{ ucfirst($payout->status) }} {{ $payout->reference ?? '—' }} {{ optional($payout->paid_at)->format('d M Y') ?? '—' }} Details CSV
💸 Payouts tab — no payouts have been created for this affiliate yet.
{{-- Tier 2 Recruits tab --}}
@forelse($affiliate->recruits as $recruit) @php $rb = match($recruit->status) { 'active' => 'badge-success', 'pending' => 'badge-warning', 'suspended' => 'badge-danger', default => 'badge-secondary', }; $t1Convs = $recruit->conversions->where('tier', 1); $t2Convs = $recruit->conversions->where('tier', 2); @endphp @empty @endforelse @if($affiliate->recruits->count()) @endif
Recruit Email Status Joined Tier 1 Conversions Tier 1 Commission Tier 2 Conversions Tier 2 Commission Earned
{{ $recruit->code }} {{ optional($recruit->user)->email ?? '—' }} {{ ucfirst($recruit->status) }} {{ $recruit->created_at->format('d M Y') }} {{ $t1Convs->count() }} ${{ number_format($t1Convs->sum('commission'), 2) }} {{ $t2Convs->count() }} @if($t2Convs->count()) ${{ number_format($t2Convs->sum('commission'), 2) }} @else @endif View →
👥 Recruits tab — this affiliate has not referred any sub-affiliates yet.
Totals: {{ $affiliate->recruits->sum(fn($r) => $r->conversions->where('tier',1)->count()) }} ${{ number_format($affiliate->recruits->sum(fn($r) => $r->conversions->where('tier',1)->sum('commission')), 2) }} {{ $affiliate->recruits->sum(fn($r) => $r->conversions->where('tier',2)->count()) }} ${{ number_format($affiliate->recruits->sum(fn($r) => $r->conversions->where('tier',2)->sum('commission')), 2) }}
@push('footer-scripts') @endpush @stop