From 3f68052276fe04c9fad182574e133afbec2fd49d Mon Sep 17 00:00:00 2001 From: Kevin Adametz Date: Fri, 19 Jun 2026 11:59:59 +0000 Subject: [PATCH] Optimierung 4.3/4.4 (Preise): Page-Data-Service + Invokable Controller Erste Seite des Web-Routen-Umbaus: die Preise-Closure aus routes/web.php in PreisePageData (Datenaufbereitung) + Web\PreiseController (schlanker Invokable Controller) verschoben. Route nutzt jetzt die Controller-Klasse. Verhalten unveraendert, Web-Tests bleiben gruen (92). Co-Authored-By: Claude Opus 4.8 (1M context) --- app/Http/Controllers/Web/PreiseController.php | 18 +++++++ app/Services/Web/PreisePageData.php | 52 +++++++++++++++++++ routes/web.php | 47 ++--------------- 3 files changed, 73 insertions(+), 44 deletions(-) create mode 100644 app/Http/Controllers/Web/PreiseController.php create mode 100644 app/Services/Web/PreisePageData.php diff --git a/app/Http/Controllers/Web/PreiseController.php b/app/Http/Controllers/Web/PreiseController.php new file mode 100644 index 00000000..ac879e32 --- /dev/null +++ b/app/Http/Controllers/Web/PreiseController.php @@ -0,0 +1,18 @@ +build()); + } +} diff --git a/app/Services/Web/PreisePageData.php b/app/Services/Web/PreisePageData.php new file mode 100644 index 00000000..9505a847 --- /dev/null +++ b/app/Services/Web/PreisePageData.php @@ -0,0 +1,52 @@ + + */ + public function build(): array + { + // Add-on-Einzelkosten aus der Credit-Ökonomie (1 Credit = 1 €). + $extraPm = collect(config('credits.extra_pm', [])) + ->map(static fn (int $credits, string $tier): array => [ + 'tier' => Tier::tryFrom($tier)?->label() ?? ucfirst($tier), + 'credits' => $credits, + ]) + ->values() + ->all(); + + $boost = collect(config('credits.boost', [])) + ->map(static fn (int $credits, int|string $days): array => [ + 'days' => (int) $days, + 'credits' => $credits, + ]) + ->values() + ->all(); + + return [ + 'plans' => Plan::query()->active()->get(), + 'singlePmPriceCents' => (int) config('billing.single_pm_price_cents'), + 'extraPm' => $extraPm, + 'boost' => $boost, + 'proofPdf' => (int) config('credits.proof_pdf'), + 'creditPacks' => config('credits.packs', []), + // TODO: Lineup/Preise hängen am Bookings-/Magic-Link-Rework — final abstimmen. + 'morePaths' => [ + 'correction' => (int) config('credits.paths.correction'), + 'update' => (int) config('credits.paths.update'), + 'depublish' => (int) config('credits.depublish'), + ], + ]; + } +} diff --git a/routes/web.php b/routes/web.php index 2b7f1170..0bb67d5e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,8 +2,8 @@ use App\Enums\Portal; use App\Enums\PressReleaseStatus; -use App\Enums\Tier; use App\Http\Controllers\PressReleasePreviewController; +use App\Http\Controllers\Web\PreiseController; use App\Http\Middleware\SetEdition; use App\Models\Category; use App\Models\Company; @@ -586,47 +586,6 @@ $veroeffentlichenPage = static function (string $edition) { ]); }; -// Preise-/Tarifseite je Ausgabe: Abos (Plan-Modell), Einzel-PM (config/billing) -// und Add-on-Einzelkosten (config/credits). Inhalte liegen in lang/*/pricing.php. -$preisePage = static function (string $edition) { - $domain = request()->getHost(); - - $domainKey = str_contains($domain, 'presseecho') ? 'presseecho' : 'businessportal24'; - DomainAssetContext::applyWebDomainConfig($domainKey); - - // Add-on-Einzelkosten aus der Credit-Ökonomie (1 Credit = 1 €). - $extraPm = collect(config('credits.extra_pm', [])) - ->map(static fn (int $credits, string $tier): array => [ - 'tier' => Tier::tryFrom($tier)?->label() ?? ucfirst($tier), - 'credits' => $credits, - ]) - ->values() - ->all(); - - $boost = collect(config('credits.boost', [])) - ->map(static fn (int $credits, int|string $days): array => [ - 'days' => (int) $days, - 'credits' => $credits, - ]) - ->values() - ->all(); - - return view('web.preise', [ - 'plans' => Plan::query()->active()->get(), - 'singlePmPriceCents' => (int) config('billing.single_pm_price_cents'), - 'extraPm' => $extraPm, - 'boost' => $boost, - 'proofPdf' => (int) config('credits.proof_pdf'), - 'creditPacks' => config('credits.packs', []), - // TODO: Lineup/Preise hängen am Bookings-/Magic-Link-Rework — final abstimmen. - 'morePaths' => [ - 'correction' => (int) config('credits.paths.correction'), - 'update' => (int) config('credits.paths.update'), - 'depublish' => (int) config('credits.depublish'), - ], - ]); -}; - // Archiv-Suchseite je Ausgabe (interaktive Suche läuft in der Volt-Komponente). $suchePage = static function (string $edition) { $context = WebPortalContext::fromRequest(); @@ -961,7 +920,7 @@ Route::get('{path}', function (string $path) use ($htmlRedirect) { // --------------------------------------------------------------------------- // Öffentliche Inhalte je Ausgabe (Sprache): /de/... und /en/... // --------------------------------------------------------------------------- -Route::prefix('{edition}')->whereIn('edition', SetEdition::EDITIONS)->group(function () use ($applyWebDomainConfig, $webHomeData, $categoryPage, $releaseDetailPage, $veroeffentlichenPage, $suchePage, $newsroomsIndex, $newsroomDetail, $preisePage) { +Route::prefix('{edition}')->whereIn('edition', SetEdition::EDITIONS)->group(function () use ($applyWebDomainConfig, $webHomeData, $categoryPage, $releaseDetailPage, $veroeffentlichenPage, $suchePage, $newsroomsIndex, $newsroomDetail) { // Startseite je Ausgabe Route::get('/', function (string $edition) use ($applyWebDomainConfig, $webHomeData) { $domain = request()->getHost(); @@ -987,7 +946,7 @@ Route::prefix('{edition}')->whereIn('edition', SetEdition::EDITIONS)->group(func Route::get('press-release/{slug}', $releaseDetailPage)->name('release.detail'); // Preise / Tarife (datengetrieben: Plan + config/billing + config/credits) - Route::get('preise', $preisePage)->name('preise'); + Route::get('preise', PreiseController::class)->name('preise'); // Statische Seiten Route::view('faq', 'web.faq')->name('faq');