@php // Récupérer le client actuel $currentClient = null; $currentClientName = null; if ($currentClientId) { $currentClient = $clients->firstWhere('client_id', $currentClientId); $currentClientName = $currentClient->client_name ?? null; } // Fonctions helper $computeInitials = function($name) { if (empty($name)) return '?'; $words = explode(' ', trim($name)); if (count($words) >= 2) { return strtoupper(substr($words[0], 0, 1) . substr($words[1], 0, 1)); } return strtoupper(substr($name, 0, 2)); }; $colorFromValue = function($value) { $colors = ['#007bff', '#28a745', '#dc3545', '#ffc107', '#17a2b8', '#6f42c1', '#e83e8c', '#fd7e14', '#20c997', '#6c757d']; $hash = crc32($value ?? ''); return $colors[abs($hash) % count($colors)]; }; // Déterminer l'affichage $hasLogo = $currentClient && $currentClient->has_custom_logo && $currentClient->client_logo && $currentClient->client_logo !== 'null'; $displayName = $currentClientName ?: 'Client inconnu'; $buttonInitials = $currentClient ? ($currentClient->initials ?? $computeInitials($currentClient->client_name)) : '?'; $buttonColor = $colorFromValue($currentClientId ?? $displayName); @endphp
@if($hasLogo) @else
{{ $buttonInitials }}
@endif
{{ $displayName }}