diff --git a/app/Http/Controllers/Web/SucheController.php b/app/Http/Controllers/Web/SucheController.php new file mode 100644 index 00000000..d999e8fa --- /dev/null +++ b/app/Http/Controllers/Web/SucheController.php @@ -0,0 +1,16 @@ +build(WebPortalContext::fromRequest())); + } +} diff --git a/app/Services/Web/SuchePageData.php b/app/Services/Web/SuchePageData.php new file mode 100644 index 00000000..255c6fe7 --- /dev/null +++ b/app/Services/Web/SuchePageData.php @@ -0,0 +1,36 @@ + + */ + 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, + ]; + } +} diff --git a/routes/web.php b/routes/web.php index 0bb67d5e..db7c8643 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,6 +4,7 @@ use App\Enums\Portal; use App\Enums\PressReleaseStatus; use App\Http\Controllers\PressReleasePreviewController; use App\Http\Controllers\Web\PreiseController; +use App\Http\Controllers\Web\SucheController; use App\Http\Middleware\SetEdition; use App\Models\Category; use App\Models\Company; @@ -586,29 +587,6 @@ $veroeffentlichenPage = static function (string $edition) { ]); }; -// Archiv-Suchseite je Ausgabe (interaktive Suche läuft in der Volt-Komponente). -$suchePage = static function (string $edition) { - $context = WebPortalContext::fromRequest(); - $language = $context->language; - $portalValues = $context->portalValues; - - $mostReadReleases = PressRelease::query() - ->withoutGlobalScope(PortalScope::class) - ->forPortalValues($portalValues) - ->forLanguage($language) - ->visibleInArchive() - ->orderByDesc('hits') - ->orderByDesc('published_at') - ->limit(5) - ->get(['id', 'slug', 'title', 'hits', 'portal', 'language']); - - return view('web.suche', [ - 'portal' => $context->portal->value, - 'language' => $language, - 'mostReadReleases' => $mostReadReleases, - ]); -}; - // Newsrooms-Verzeichnis je Ausgabe: alle aktiven Unternehmen mit Meldungen. $newsroomsIndex = static function (string $edition) { $context = WebPortalContext::fromRequest(); @@ -920,7 +898,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) { +Route::prefix('{edition}')->whereIn('edition', SetEdition::EDITIONS)->group(function () use ($applyWebDomainConfig, $webHomeData, $categoryPage, $releaseDetailPage, $veroeffentlichenPage, $newsroomsIndex, $newsroomDetail) { // Startseite je Ausgabe Route::get('/', function (string $edition) use ($applyWebDomainConfig, $webHomeData) { $domain = request()->getHost(); @@ -953,7 +931,7 @@ Route::prefix('{edition}')->whereIn('edition', SetEdition::EDITIONS)->group(func Route::view('kontakt', 'web.kontakt')->name('kontakt'); Route::view('ueber-uns', 'web.ueber-uns')->name('ueber-uns'); Route::get('veroeffentlichen', $veroeffentlichenPage)->name('veroeffentlichen'); - Route::get('suche', $suchePage)->name('suche'); + Route::get('suche', SucheController::class)->name('suche'); Route::get('newsrooms', $newsroomsIndex)->name('newsrooms'); Route::get('newsroom/{slug}', $newsroomDetail)->name('newsroom'); Route::view('api', 'web.api')->name('api');