{{-- resources/views/agent/clients.blade.php --}} @extends('layouts.contentLayoutMaster') @section('title', 'My Clients') @section('content') @php use Illuminate\Support\Facades\Route as R; // Helper: humanize snake-case types (e.g., "term_life" => "Term Life") $humanize = function (?string $val) { if (!$val) return 'N/A'; $v = str_replace('_', ' ', trim($val)); return $v !== '' ? ucwords($v) : 'N/A'; }; @endphp
{{-- Flash messages --}} @if (session('status'))
{{ session('status') }}
@endif @if (session('error'))
{{ session('error') }}
@endif {{-- Header --}}
{{-- Left: Title only --}}

My Clients

{{-- Right: Actions + Export + Search + Appointments --}}
{{-- Actions (bulk) --}} {{-- Export --}} Export {{-- Search --}}
@if (request('search')) Clear @endif {{-- Global Appointments list for the agent --}} @if (R::has('agent.appointments.index')) Appointments @endif
{{-- Only tighten the Email column + Actions column --}} {{-- Bulk form wraps the table so selected IDs submit together --}}
@csrf {{-- POST route name must be agent.clients.bulkDestroy --}}
@forelse ($clients as $client) @php $fname = trim($client->first_name ?? ''); $lname = trim($client->last_name ?? ''); $name = trim($fname . ' ' . $lname) ?: 'N/A'; $email = $client->email ?? null; $phone = $client->phone_number ?? 'N/A'; $city = trim((string) ($client->city ?? '')); $state = trim((string) ($client->state ?? '')); $cityState = $city && $state ? "{$city}, {$state}" : ($city ?: ($state ?: 'N/A')); $rawType = strtolower(trim($client->lead_type ?? ($client->source ?? ($client->origin ?? '')))); $typeMap = [ 'assigned' => ['Assigned', 'bg-secondary'], 'assigned lead' => ['Assigned', 'bg-secondary'], 'personal' => ['Personal', 'bg-dark'], 'personal lead' => ['Personal', 'bg-dark'], 'purchased' => ['Purchased', 'bg-primary'], 'purchased lead' => ['Purchased', 'bg-primary'], 'social' => ['Social Media', 'bg-info text-dark'], 'social media' => ['Social Media', 'bg-info text-dark'], 'social media lead' => ['Social Media', 'bg-info text-dark'], ]; [$leadLabel, $leadClass] = $typeMap[$rawType] ?? [ $rawType ? ucwords($rawType) : 'N/A', $rawType ? 'bg-light text-dark' : 'bg-light text-muted', ]; $insLabel = $humanize($client->insurance_type ?? null); @endphp {{-- Tightened email column --}} {{-- Lead Type --}} {{-- Actions (centered) --}} @empty @endforelse
Name Phone City / State Insurance Type Lead Type Actions
{{ $name }} {{ $phone }} {{ $cityState }} {{ $insLabel }} {{ $leadLabel }}
View @if (R::has('agent.appointments.create')) Schedule @endif
No clients assigned to you yet.
{{-- Pagination (if using ->paginate()) --}} @if (method_exists($clients, 'links'))
{{ $clients->links() }}
@endif
{{-- Minimal JS: just Select All (delete works without JS) --}} @push('scripts') @endpush @endsection