Suche-Closure in SuchePageData + Web\SucheController verschoben. Verhalten unveraendert, 92 Web-Tests gruen. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
36 lines
1 KiB
PHP
36 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Web;
|
|
|
|
use App\Models\PressRelease;
|
|
use App\Scopes\PortalScope;
|
|
use App\Support\WebPortalContext;
|
|
|
|
/**
|
|
* Datenaufbereitung der Archiv-Suchseite. Die eigentliche Suche läuft in der
|
|
* Volt-Komponente; hier wird nur die „Meistgelesen"-Seitenleiste geliefert.
|
|
*/
|
|
class SuchePageData
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function build(WebPortalContext $context): array
|
|
{
|
|
$mostReadReleases = PressRelease::query()
|
|
->withoutGlobalScope(PortalScope::class)
|
|
->forPortalValues($context->portalValues)
|
|
->forLanguage($context->language)
|
|
->visibleInArchive()
|
|
->orderByDesc('hits')
|
|
->orderByDesc('published_at')
|
|
->limit(5)
|
|
->get(['id', 'slug', 'title', 'hits', 'portal', 'language']);
|
|
|
|
return [
|
|
'portal' => $context->portal->value,
|
|
'language' => $context->language,
|
|
'mostReadReleases' => $mostReadReleases,
|
|
];
|
|
}
|
|
}
|