@extends('layouts.dashboard') @section('title', 'User Details') @section('page-title', 'User Details: ' . $user->name) @section('content') @php $canViewCalls = auth()->guard('admin')->user()->hasPermission('logs.call.view'); $canViewSms = auth()->guard('admin')->user()->hasPermission('logs.sms.view'); $canViewPromos = auth()->guard('admin')->user()->hasPermission('logs.promotion.view'); $hasLogsPermission = $canViewCalls || $canViewSms; $canViewWhatsApp = $canViewSms; // WhatsApp visibility follows SMS permission $visibleStatsCount = ($canViewCalls ? 1 : 0) + ($canViewSms ? 1 : 0) + ($canViewWhatsApp ? 1 : 0) + ($canViewPromos ? 1 : 0); $colSize = $visibleStatsCount > 0 ? max(3, floor(12 / $visibleStatsCount)) : 12; $settings = $user->settings; @endphp
Back to Users
@if(auth()->guard('admin')->user()->hasPermission('users.edit')) Edit User @endif @if(auth()->guard('admin')->user()->hasPermission('users.toggle_status'))
@csrf
@endif @if(auth()->guard('admin')->user()->hasPermission('users.toggle_sms'))
@csrf
@csrf
@endif @if(auth()->guard('admin')->user()->hasPermission('users.force_logout'))
@csrf
@endif
@if(session('success')) @endif
User Information
@if($user->is_active) Active @else Inactive @endif
ID {{ $user->id }}
Name {{ $user->name }}
Email {{ $user->email }}
Phone {{ $user->phone }}
SMS Service @if($user->sms_service_enabled) Enabled @else Disabled @endif
WhatsApp @if($settings && $settings->whatsapp_enabled) Enabled @else Disabled @endif
Channel @php $channel = $settings->preferred_channel ?? 'sms'; $channelLabel = match($channel) { 'whatsapp' => 'WhatsApp Only', 'both' => 'Both (SMS + WA)', default => 'SMS Only', }; $channelBadge = match($channel) { 'whatsapp' => 'bg-success', 'both' => 'bg-info', default => 'bg-primary', }; @endphp {{ $channelLabel }}
Promotions @if($user->promotions_enabled) Enabled @else Disabled @endif
Last Active {{ $user->last_active_at?->diffForHumans() ?? 'Never' }}
Registered {{ $user->created_at->format('M d, Y H:i') }}
@if($visibleStatsCount > 0)
Statistics
@if($canViewCalls)

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

Calls
@endif @if($canViewSms)

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

SMS
@endif @if($canViewWhatsApp)

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

WhatsApp
@endif @if($canViewPromos)

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

Promos
@endif
@endif
@if($hasLogsPermission) {{-- Render Settings and Templates on the left if Logs are visible on right --}} @include('dashboard.partials.user-settings-block', ['settings' => $settings]) @include('dashboard.partials.user-templates-block', ['templates' => $user->messageTemplates, 'user_id' => $user->id]) @endif
@if($hasLogsPermission)
@if($canViewCalls)
@forelse($callLogs as $call) @empty @endforelse
Phone Number Type SMS Sent Time
{{ $call->phone_number }} {{ ucfirst($call->call_type) }} @if($call->sms_sent) Yes @else No @endif {{ $call->call_time->format('M d, Y H:i') }}
No call logs
@if(method_exists($callLogs, 'links')) {{ $callLogs->fragment('callLogs')->links() }} @endif
@endif @if($canViewSms)
@forelse($smsLogs as $sms) @empty @endforelse
Phone Number Channel Message Status Sent At
{{ $sms->phone_number }} @if(($sms->channel ?? 'sms') === 'whatsapp') WhatsApp @else SMS @endif {{ Str::limit($sms->message, 40) }} {{ ucfirst($sms->status) }} {{ $sms->sent_at?->format('M d, Y H:i') ?? '-' }}
No SMS / WhatsApp logs
@if(method_exists($smsLogs, 'links')) {{ $smsLogs->fragment('smsLogs')->links() }} @endif
@endif @if($canViewPromos)
@forelse($promotionLogs as $promo) @empty @endforelse
Phone Number Message Trigger Status Sent At
{{ $promo->phone_number }} {{ Str::limit($promo->message, 40) }} {{ ucfirst($promo->trigger_type) }} {{ ucfirst($promo->status) }} {{ $promo->sent_at?->format('M d, Y H:i') ?? '-' }}
No promotion logs
@if(method_exists($promotionLogs, 'links')) {{ $promotionLogs->fragment('promoLogs')->links() }} @endif
@endif
@else {{-- Logs are hidden: Show Settings and Templates here in a Wide format --}}
@include('dashboard.partials.user-settings-block', ['settings' => $settings, 'wide' => true])
@include('dashboard.partials.user-templates-block', ['templates' => $user->messageTemplates, 'user_id' => $user->id, 'wide' => true])
@endif
@endsection