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) <noreply@anthropic.com>
This commit is contained in:
parent
714a5cd5b1
commit
3f68052276
3 changed files with 73 additions and 44 deletions
18
app/Http/Controllers/Web/PreiseController.php
Normal file
18
app/Http/Controllers/Web/PreiseController.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Web\PreisePageData;
|
||||
use App\Support\WebPortalContext;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
class PreiseController extends Controller
|
||||
{
|
||||
public function __invoke(PreisePageData $pageData): View
|
||||
{
|
||||
WebPortalContext::fromRequest();
|
||||
|
||||
return view('web.preise', $pageData->build());
|
||||
}
|
||||
}
|
||||
52
app/Services/Web/PreisePageData.php
Normal file
52
app/Services/Web/PreisePageData.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Web;
|
||||
|
||||
use App\Enums\Tier;
|
||||
use App\Models\Plan;
|
||||
|
||||
/**
|
||||
* Datenaufbereitung der öffentlichen Preise-/Tarifseite: Abos (Plan-Modell),
|
||||
* Einzel-PM (config/billing) und Add-on-Einzelkosten (config/credits).
|
||||
* Inhalte liegen in lang/*\/pricing.php.
|
||||
*/
|
||||
class PreisePageData
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
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'),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue