Optimierung 2.9: HandlesAdminPressReleaseActions::findAdminPR()

Den ~15x duplizierten Admin-Lookup PressRelease::withoutGlobalScopes()
->findOrFail($id) in einen findAdminPR()-Helfer (Concern) zentralisiert;
index/edit/show nutzen ihn. Die eager-load-Query in show::with() bleibt
unberuehrt (anderer Zweck).

Bewusst NICHT vereinheitlicht: das Status-Badge-Mapping divergiert real
(index: archived/draft -> muted; edit/show: -> hub via default) -> waere
eine Design-Entscheidung ueber kanonische Badge-Farben, keine mechanische
Dedup.

Tests: volle Suite gruen (799 passed, 1 skipped).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-06-19 10:11:48 +00:00
parent 86ba6c1a51
commit 3a18a2b494
4 changed files with 38 additions and 15 deletions

View file

@ -12,6 +12,8 @@ use Livewire\Volt\Component;
new #[Layout('components.layouts.app'), Title('Pressemitteilung')] class extends Component
{
use \App\Livewire\Concerns\HandlesAdminPressReleaseActions;
#[Locked]
public int $id;
@ -24,7 +26,7 @@ new #[Layout('components.layouts.app'), Title('Pressemitteilung')] class extends
public function publish(): void
{
$pr = PressRelease::withoutGlobalScopes()->findOrFail($this->id);
$pr = $this->findAdminPR($this->id);
try {
app(PressReleaseService::class)->publish($pr);
@ -50,7 +52,7 @@ new #[Layout('components.layouts.app'), Title('Pressemitteilung')] class extends
'rejectReason' => ['required', 'string', 'min:5', 'max:2000'],
]);
$pr = PressRelease::withoutGlobalScopes()->findOrFail($this->id);
$pr = $this->findAdminPR($this->id);
app(PressReleaseService::class)->reject($pr, trim($this->rejectReason));
$this->rejectReason = '';
@ -61,7 +63,7 @@ new #[Layout('components.layouts.app'), Title('Pressemitteilung')] class extends
public function archive(): void
{
$pr = PressRelease::withoutGlobalScopes()->findOrFail($this->id);
$pr = $this->findAdminPR($this->id);
app(PressReleaseService::class)->archive($pr);
Flux::toast(text: __('Archiviert.'), variant: 'success');
Flux::modal('confirm-show-archive')->close();