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>
49 lines
1.8 KiB
PHP
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(),
|
|
];
|
|
}),
|
|
];
|
|
}
|
|
}
|