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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue