presseportale/app/Services/Web/HubPageData.php
Kevin Adametz f6edb4aec5 R2.2: HubPageData - Plan-Katalog + echte Plattform-Kennzahlen fuer die Hub-Landing
Liefert Plan::active(), Einzel-PM-Preis und stuendlich gecachte echte
Zahlen (Archiv-Mitteilungen gesamt/je Portal, aktive Newsrooms,
Branchen) an web.pressekonto. Tests: Katalog-Preise statt Fake-Liste,
keine toten Links/erfundenen Referenzen, Rechtsseiten auf der
Hub-Domain erreichbar. (Gehoert zum Web-Commit der Hub-Ueberarbeitung.)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 09:24:04 +00:00

49 lines
1.8 KiB
PHP

<?php
namespace App\Services\Web;
use App\Enums\Portal;
use App\Models\Category;
use App\Models\Company;
use App\Models\Plan;
use App\Models\PressRelease;
use App\Scopes\PortalScope;
use Illuminate\Support\Facades\Cache;
/**
* Datenaufbereitung der Hub-Landing (pressekonto.de): aktiver Tarif-Katalog
* plus echte Plattform-Kennzahlen statt statischer Marketing-Zahlen.
*/
class HubPageData
{
private const StatsCacheKey = 'web.hub.landing-stats';
private const StatsTtlSeconds = 3600;
/**
* @return array<string, mixed>
*/
public function build(): array
{
return [
'plans' => Plan::query()->active()->get(),
'singlePmPriceCents' => (int) config('billing.single_pm_price_cents'),
'hubStats' => Cache::remember(self::StatsCacheKey, self::StatsTtlSeconds, function (): array {
$published = PressRelease::query()
->withoutGlobalScope(PortalScope::class)
->visibleInArchive();
return [
'releases_total' => (clone $published)->count(),
'releases_presseecho' => (clone $published)->forPortalValues([Portal::Presseecho->value, Portal::Both->value])->count(),
'releases_businessportal' => (clone $published)->forPortalValues([Portal::Businessportal24->value, Portal::Both->value])->count(),
'newsrooms' => Company::query()
->withoutGlobalScope(PortalScope::class)
->whereHas('pressReleases', fn ($query) => $query->withoutGlobalScope(PortalScope::class)->visibleInArchive())
->count(),
'categories' => Category::query()->withoutGlobalScope(PortalScope::class)->count(),
];
}),
];
}
}