get($key, $default); } } if (!function_exists('domain_host')) { function domain_host(string $sub = null): string { $base = env('BASE_DOMAIN', 'example.com'); return $sub ? "{$sub}.{$base}" : $base; } } if (!function_exists('ui_host')) { function ui_host(): string { return domain_host(env('UI_SUB', 'ui')); } } if (!function_exists('webmail_host')) { function webmail_host(): string { return domain_host(env('WEBMAIL_SUB', 'webmail')); } } if (!function_exists('mta_host')) { function mta_host(?int $domainId = null): string { // 1️⃣ Vorrang: Datenbankwert (z. B. aus der domains-Tabelle) if ($domainId) { try { $domain = \App\Models\Domain::find($domainId); if ($domain && !empty($domain->mta_host)) { return $domain->mta_host; } } catch (\Throwable $e) { // DB evtl. noch nicht migriert — fallback auf env } } // 2️⃣ ENV-Variante (z. B. MTA_SUB=mail01) $sub = env('MTA_SUB'); if ($sub) { return domain_host($sub); } // 3️⃣ Notfall: statischer Fallback return domain_host('mx'); } } if (! function_exists('countryFlag')) { /** * Gibt das Flag-Emoji eines Landes zurück anhand des ISO-Codes (z. B. "de" → 🇩🇪). */ function countryFlag(string $code): string { $code = strtoupper($code); // Unicode-Magic: A -> 🇦, B -> 🇧 etc. return implode('', array_map( fn($char) => mb_chr(ord($char) + 127397, 'UTF-8'), str_split($code) )); } }