neuer checkout-pfad: /de/bestellen/paketID und /en/checkout/PackageID
This commit is contained in:
28
app/Support/CheckoutRoutes.php
Normal file
28
app/Support/CheckoutRoutes.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\Package;
|
||||
|
||||
class CheckoutRoutes
|
||||
{
|
||||
public static function slugForLocale(?string $locale = null): string
|
||||
{
|
||||
$normalized = LocaleConfig::canonicalize($locale ?? app()->getLocale());
|
||||
|
||||
return $normalized === 'en' ? 'checkout' : 'bestellen';
|
||||
}
|
||||
|
||||
public static function wizardUrl(Package|int $package, ?string $locale = null): string
|
||||
{
|
||||
$normalized = LocaleConfig::canonicalize($locale ?? app()->getLocale());
|
||||
$slug = self::slugForLocale($normalized);
|
||||
$packageId = $package instanceof Package ? $package->getKey() : $package;
|
||||
|
||||
return route('checkout.show', [
|
||||
'locale' => $normalized,
|
||||
'checkoutSlug' => $slug,
|
||||
'package' => $packageId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user