mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2025-12-14 12:06:46 +00:00
🌍 Refactor domain image logic into reusable helper function
- Moved domain image selection logic into `get_domain_image` helper for reusability. - Simplified `app-logo-icon.blade.php` and `SeoDataAttribute` by replacing inline logic with the new helper. - Improved maintainability and consistency for handling `lang_country` sessions.
This commit is contained in:
@@ -17,28 +17,7 @@ class SeoDataAttribute
|
||||
|
||||
private static function initDefinitions(): void
|
||||
{
|
||||
$langCountry = session('lang_country', 'de-DE');
|
||||
$domainImage = asset('img/domains/'.$langCountry.'.jpg');
|
||||
if (!file_exists(public_path('img/domains/'.$langCountry.'.jpg'))) {
|
||||
$langCountry = 'de-DE';
|
||||
}
|
||||
$southAmericanCountries = [
|
||||
'ar-AR', // Argentina
|
||||
'bo-BO', // Bolivia
|
||||
'br-BR', // Brazil
|
||||
'cl-CL', // Chile
|
||||
'co-CO', // Colombia
|
||||
'ec-EC', // Ecuador
|
||||
'gy-GY', // Guyana
|
||||
'py-PY', // Paraguay
|
||||
'pe-PE', // Peru
|
||||
'sr-SR', // Suriname
|
||||
'uy-UY', // Uruguay
|
||||
've-VE', // Venezuela
|
||||
];
|
||||
if (in_array($langCountry, $southAmericanCountries, true)) {
|
||||
$domainImage = asset('img/domains/lat.png');
|
||||
}
|
||||
$domainImage = get_domain_image();
|
||||
|
||||
self::$seoDefinitions = [
|
||||
'login' => new SEOData(
|
||||
|
||||
@@ -13,3 +13,37 @@ if (!function_exists('route_with_country')) {
|
||||
return route($name, $parameters, $absolute);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_domain_image')) {
|
||||
function get_domain_image(): string
|
||||
{
|
||||
$langCountry = session('lang_country', 'de-DE');
|
||||
|
||||
// Check if specific domain image exists
|
||||
if (!file_exists(public_path('img/domains/'.$langCountry.'.jpg'))) {
|
||||
$langCountry = 'de-DE';
|
||||
}
|
||||
|
||||
$southAmericanCountries = [
|
||||
'ar-AR', // Argentina
|
||||
'bo-BO', // Bolivia
|
||||
'br-BR', // Brazil
|
||||
'cl-CL', // Chile
|
||||
'co-CO', // Colombia
|
||||
'ec-EC', // Ecuador
|
||||
'gy-GY', // Guyana
|
||||
'py-PY', // Paraguay
|
||||
'pe-PE', // Peru
|
||||
'sr-SR', // Suriname
|
||||
'uy-UY', // Uruguay
|
||||
've-VE', // Venezuela
|
||||
];
|
||||
|
||||
// Use LAT image for South American countries
|
||||
if (in_array($langCountry, $southAmericanCountries, true)) {
|
||||
return asset('img/domains/lat.png');
|
||||
}
|
||||
|
||||
return asset('img/domains/'.$langCountry.'.jpg');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,4 @@
|
||||
@php
|
||||
$langCountry = session('lang_country', 'de-DE');
|
||||
$domainImage = asset('img/domains/'.$langCountry.'.jpg');
|
||||
if (!file_exists(public_path('img/domains/'.$langCountry.'.jpg'))) {
|
||||
$langCountry = 'de-DE';
|
||||
}
|
||||
$southAmericanCountries = [
|
||||
'ar-AR', // Argentina
|
||||
'bo-BO', // Bolivia
|
||||
'br-BR', // Brazil
|
||||
'cl-CL', // Chile
|
||||
'co-CO', // Colombia
|
||||
'ec-EC', // Ecuador
|
||||
'gy-GY', // Guyana
|
||||
'py-PY', // Paraguay
|
||||
'pe-PE', // Peru
|
||||
'sr-SR', // Suriname
|
||||
'uy-UY', // Uruguay
|
||||
've-VE', // Venezuela
|
||||
];
|
||||
if (in_array($langCountry, $southAmericanCountries, true)) {
|
||||
$domainImage = asset('img/domains/lat.png');
|
||||
}
|
||||
@endphp
|
||||
|
||||
@if($langCountry === 'de-DE')
|
||||
@if(session('lang_country', 'de-DE') === 'de-DE')
|
||||
<svg viewBox="0 0 1287 1287" version="1.1" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g>
|
||||
@@ -41,5 +16,5 @@
|
||||
</g>
|
||||
</svg>
|
||||
@else
|
||||
<img src="{{ $domainImage }}" alt="{{ $langCountry }}">
|
||||
<img src="{{ get_domain_image() }}" alt="{{ session('lang_country', 'de-DE') }}">
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user