commit 08-2025

This commit is contained in:
Kevin Adametz 2025-08-12 18:01:59 +02:00
parent 9ae662f63e
commit 480fdc65ed
404 changed files with 65310 additions and 2600431 deletions

View file

@ -1,6 +1,8 @@
<?php
use App\Services\AboHelper;
use App\Domain\DomainContext;
use App\Services\DomainService;
if (! function_exists('make_old_url')) {
function make_old_url($path)
@ -105,4 +107,84 @@ if (! function_exists('cleanIntegerFromString')) {
function cleanIntegerFromString($value) {
return Util::cleanIntegerFromString($value);
}
}
if (! function_exists('legal_url')) {
/**
* Generate URL for legal pages that should always point to shop domain from checkout
*/
function legal_url($path) {
try {
$context = app(DomainContext::class);
// If we're on checkout domain, redirect legal links to shop domain
if ($context->type === 'checkout') {
$domainService = app(DomainService::class);
return $domainService->buildUrl('main', $path);
}
// For all other domains, use normal URL generation
return url($path);
} catch (Exception $e) {
// Fallback to normal URL if something goes wrong
return url($path);
}
}
}
if (! function_exists('main_asset')) {
/**
* Generate an asset URL using the main domain to avoid CORS issues.
* This ensures all assets are loaded from the main domain regardless of subdomain.
*/
function main_asset($path)
{
// Entferne führende Slashes
$path = ltrim($path, '/');
// Baue die Hauptdomain-URL
$protocol = config('app.protocol', 'https://');
$domain = config('app.domain', 'mivita');
$tld = config('app.tld_care', '.care');
return $protocol . $domain . $tld . '/' . $path;
}
}
if (! function_exists('cors_asset')) {
/**
* Alias for main_asset for backward compatibility and clarity.
*/
function cors_asset($path)
{
return main_asset($path);
}
}
if (!function_exists('route')) {
/**
* Route auf Hauptdomain generieren
*/
function route($name, $parameters = [], $absolute = true)
{
$url = route($name, $parameters, $absolute);
// Ersetze Subdomain mit Hauptdomain
if (request()->hasHeader('X-Subdomain')) {
$currentHost = request()->getHost();
$url = str_replace($currentHost, config('app.domain').config('app.tld_care'), $url);
}
return $url;
}
}
if (!function_exists('asset_route')) {
/**
* Asset/Storage Route immer auf Hauptdomain
*/
function asset_route($name, $parameters = [])
{
return 'https://' . config('app.domain') . config('app.tld_care') . route($name, $parameters, false);
}
}