Optimierung 4.3/4.4 (Suche): Page-Data-Service + Invokable Controller
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>
This commit is contained in:
parent
7625ec7ed5
commit
418a2bca4c
3 changed files with 55 additions and 25 deletions
16
app/Http/Controllers/Web/SucheController.php
Normal file
16
app/Http/Controllers/Web/SucheController.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Web\SuchePageData;
|
||||
use App\Support\WebPortalContext;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
class SucheController extends Controller
|
||||
{
|
||||
public function __invoke(SuchePageData $pageData): View
|
||||
{
|
||||
return view('web.suche', $pageData->build(WebPortalContext::fromRequest()));
|
||||
}
|
||||
}
|
||||
36
app/Services/Web/SuchePageData.php
Normal file
36
app/Services/Web/SuchePageData.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue