@extends('layouts.app') @section('title', 'User Details - ' . ($user->username ?? $user->email)) @section('content')
{{-- Breadcrumb / Page Header --}}

{{ $user->username ?? $user->email }}

{{-- User Profile Header --}}
{{-- Avatar --}}
@if($user->avatar) {{ $user->username }} @else
{{ Str::upper(Str::substr($user->username ?? $user->email ?? 'U', 0, 2)) }}
@endif
{{-- User Info --}}

{{ $user->username ?? 'No username' }}

@if($user->banned) Banned @else Active @endif
{{ $user->email }} @if($user->email_status) Verified @else Unverified @endif
@if($user->phone_number)
{{ $user->phone_number }}
@endif
Role {{ $user->role?->display_name ?? 'Member' }}
Joined {{ $user->created_at ? $user->created_at->format('M d, Y') : 'N/A' }} ({{ $user->created_at ? $user->created_at->diffForHumans() : '' }})
{{-- Quick Actions --}}
@php $currentUser = auth()->user(); $canManageUsers = $currentUser?->role?->hasPermission( 'users.manage' ) ?? false; $isOwnAccount = (int) $currentUser?->id === (int) $user->id; $isProtectedSuperAdministrator = (bool) ($user->role?->is_super_admin ?? false); @endphp @if($canManageUsers && !$isOwnAccount && !$isProtectedSuperAdministrator) {{-- Ban or Unban --}}
@csrf @method('PATCH')
{{-- Verify or Unverify Email --}}
@csrf @method('PATCH')
{{-- Edit --}} Edit User @elseif($isProtectedSuperAdministrator)
The Super Administrator account is protected.
@elseif($isOwnAccount)
You cannot deactivate your own account.
@else
You do not have permission to manage this account.
@endif
{{-- Stats Row --}}
@php $statsCurrency = currency_code( $stats['currency'] ?? default_currency() ); $detailStats = [ [ 'label' => 'Total Orders', 'value' => number_format( (int) ($stats['total_orders'] ?? 0) ), 'icon' => 'fa-shopping-bag', 'color' => 'primary', ], [ 'label' => 'Total Spent', 'value' => money( $stats['total_spent'] ?? 0, $statsCurrency ), 'icon' => 'fa-money-bill-wave', 'color' => 'success', ], [ 'label' => 'Avg Order Value', 'value' => money( $stats['avg_order_value'] ?? 0, $statsCurrency ), 'icon' => 'fa-calculator', 'color' => 'info', ], [ 'label' => 'Total Refunds', 'value' => number_format( (int) ($stats['total_refunds'] ?? 0) ), 'icon' => 'fa-undo', 'color' => 'warning', ], [ 'label' => 'Total Products', 'value' => number_format( (int) ($stats['total_products'] ?? 0) ), 'icon' => 'fa-cube', 'color' => 'secondary', ], [ 'label' => 'Active Products', 'value' => number_format( (int) ($stats['active_products'] ?? 0) ), 'icon' => 'fa-check-circle', 'color' => 'success', ], [ 'label' => 'Total Earnings', 'value' => money( $stats['total_earnings'] ?? 0, $statsCurrency ), 'icon' => 'fa-coins', 'color' => 'warning', ], [ 'label' => 'Wallet Balance', 'value' => money( $stats['balance'] ?? 0, $statsCurrency ), 'icon' => 'fa-wallet', 'color' => 'primary', ], [ 'label' => 'Total Payouts', 'value' => money( $stats['total_payouts'] ?? 0, $statsCurrency ), 'icon' => 'fa-money-bill-alt', 'color' => 'success', ], [ 'label' => 'Pending Payouts', 'value' => money( $stats['pending_payouts'] ?? 0, $statsCurrency ), 'icon' => 'fa-clock', 'color' => 'warning', ], ]; @endphp @foreach($detailStats as $stat)

{{ $stat['label'] }}

{{ $stat['value'] }}
@endforeach
{{-- Tabs --}}
{{-- Orders Tab --}}
@include('admin.users.partials.tab-orders', ['orders' => $orders])
{{-- Transactions Tab --}}
@include('admin.users.partials.tab-transactions', ['transactions' => $transactions])
{{-- Products Tab --}}
@include('admin.users.partials.tab-products', ['products' => $products])
{{-- Wallet Tab --}}
@include('admin.users.partials.tab-wallet', [ 'walletEntries' => $walletEntries, 'user' => $user, 'stats' => $stats ])
{{-- Refunds Tab --}}
@include('admin.users.partials.tab-refunds', ['refunds' => $refunds])
{{-- Activity Tab --}}
@include('admin.users.partials.tab-activity', [ 'loginActivities' => $loginActivities, 'followers' => $followers, 'following' => $following, 'reviewsGiven' => $reviewsGiven, 'reviewsReceived' => $reviewsReceived, 'membership' => $membership, ])
{{-- Affiliate Tab --}} @if($user->role?->is_vendor)
@include('admin.users.partials.tab-affiliate', [ 'affiliateEarnings' => $affiliateEarnings, 'affiliateClicks' => $affiliateClicks, 'user' => $user, ])
@endif
@endsection @push('styles') @endpush