id = $id; $pr = $this->findAdminPR($id); $this->portal = $pr->portal->value; $this->language = $pr->language; $this->companyId = $pr->company_id; $this->categoryId = $pr->category_id; $this->title = $pr->title; $this->subtitle = $pr->subtitle ?? ''; $this->text = $pr->text; $this->keywords = $pr->keywords ?? ''; $this->backlinkUrl = $pr->backlink_url ?? ''; $this->boilerplateOverride = $pr->boilerplate_override ?? ''; $this->useBoilerplateOverride = filled($pr->boilerplate_override); $this->noExport = $pr->no_export; $this->currentStatus = $pr->status->value; $this->targetStatus = $this->currentStatus; $this->contactId = $pr->contacts()->withoutGlobalScopes()->first()?->id ?? $this->defaultContactIdFor((int) $pr->company_id); if ($pr->scheduled_at) { $scheduledAt = $pr->scheduled_at; $this->publishMode = 'scheduled'; $this->scheduledAt = $scheduledAt->format('Y-m-d\TH:i'); $this->scheduledDate = $scheduledAt->format('Y-m-d'); $this->scheduledTime = $scheduledAt->format('H:i'); } } public function updatedCompanySearch(): void { $this->resetErrorBag('companyId'); } public function updatedCompanyId(): void { if (!$this->companyId) { $this->contactId = null; return; } $contactStillValid = $this->companyContact((int) $this->contactId, (int) $this->companyId); if (!$contactStillValid) { $this->contactId = $this->defaultContactIdFor((int) $this->companyId); } unset($this->presubmitChecks); } /** * @return array> */ protected function formRules(): array { return [ ...$this->baseFormRules(), 'portal' => ['required', Rule::in(array_map(fn(Portal $p) => $p->value, Portal::cases()))], 'companyId' => ['required', 'integer', Rule::exists('companies', 'id')], ]; } public function save(): void { $this->syncScheduledAt(); $this->useEmbargo = false; $this->embargoAt = null; try { $this->validate($this->formRules()); } catch (\Illuminate\Validation\ValidationException $e) { $this->notifyValidationError($e); throw $e; } $pr = $this->findAdminPR($this->id); if ($pr->title !== $this->title || $pr->portal !== $this->portal || $pr->language !== $this->language) { $slug = $pr->generateUniqueSlug($this->title, [ 'portal' => $this->portal, 'language' => $this->language, ]); } else { $slug = $pr->slug; } $cleanText = app(PressReleaseHtmlSanitizer::class)->clean($this->text); $pr->update([ 'portal' => $this->portal, 'language' => $this->language, 'company_id' => (int) $this->companyId, 'category_id' => (int) $this->categoryId, 'title' => $this->title, 'subtitle' => trim($this->subtitle) ?: null, 'slug' => $slug, 'text' => $cleanText, 'boilerplate_override' => $this->useBoilerplateOverride && trim($this->boilerplateOverride) !== '' ? trim($this->boilerplateOverride) : null, 'keywords' => $this->keywords ?: null, 'backlink_url' => $this->backlinkUrl ?: null, 'scheduled_at' => $this->publishMode === 'scheduled' ? $this->resolveScheduledAt() : null, 'embargo_at' => null, 'no_export' => $this->noExport, ]); $contentChanged = $pr->wasChanged(['title', 'text']); if ($this->contactId) { $contact = $this->companyContact((int) $this->contactId, (int) $this->companyId); if ($contact) { $pr->contacts()->sync([$contact->id]); } } // Inhaltliche Änderung einer bereits geprüften/bewerteten PM → neu // prüfen (Re-Check ohne Routing) und neu bewerten. if ($contentChanged) { app(PressReleaseService::class)->reprocessAfterContentChange($pr); } Flux::toast(text: __('Pressemitteilung gespeichert.'), variant: 'success'); } public function submitForReview(): void { $pr = $this->findAdminPR($this->id); try { app(PressReleaseService::class)->submitForReview($pr); } catch (BlacklistViolationException $e) { $this->currentStatus = PressReleaseStatus::Rejected->value; Flux::toast(heading: __('Automatisch abgelehnt'), text: __('Unzulässiges Wort gefunden: ":word".', ['word' => $e->word]), variant: 'danger', duration: 8000); return; } $this->currentStatus = PressReleaseStatus::Review->value; Flux::toast(text: __('Zur Prüfung eingereicht.'), variant: 'success'); } /** * Stößt eine manuelle KI-Prüfung im Hintergrund an (Re-Check). * * Anders als beim Einreichen wird hier NICHT geroutet (Status bleibt * unverändert): Das Ergebnis aktualisiert nur Klassifikation + Audit, die * Entscheidung trifft der Admin weiterhin selbst. */ public function runKiCheck(): void { if (! $this->kiRunClassification && ! $this->kiRunContentScore) { Flux::toast(text: __('Es wurde keine Prüfung ausgewählt.'), variant: 'warning'); return; } $provider = $this->kiProvider === 'default' ? null : $this->kiProvider; if ($this->kiRunClassification) { ClassifyPressRelease::dispatch($this->id, route: false, providerOverride: $provider) ->onQueue('classification'); } if ($this->kiRunContentScore) { ScorePressRelease::dispatch($this->id, providerOverride: $provider) ->onQueue('classification'); } Flux::modal('admin-ki-check')->close(); Flux::toast( heading: __('KI-Prüfung gestartet'), text: __('Die Prüfung läuft im Hintergrund. Das Ergebnis erscheint nach Abschluss in der Detailansicht.'), variant: 'success', duration: 7000, ); } public function publish(): void { $pr = $this->findAdminPR($this->id); try { app(PressReleaseService::class)->publish($pr); } catch (BlacklistViolationException $e) { $this->currentStatus = PressReleaseStatus::Rejected->value; Flux::toast(heading: __('Automatisch abgelehnt'), text: __('Unzulässiges Wort gefunden: ":word".', ['word' => $e->word]), variant: 'danger', duration: 8000); return; } $this->currentStatus = PressReleaseStatus::Published->value; Flux::toast(text: __('Pressemitteilung veröffentlicht. Autor wurde benachrichtigt.'), variant: 'success'); } public function reject(): void { $pr = $this->findAdminPR($this->id); app(PressReleaseService::class)->reject($pr); $this->currentStatus = PressReleaseStatus::Rejected->value; Flux::toast(text: __('Pressemitteilung abgelehnt. Autor wurde benachrichtigt.'), variant: 'warning'); } public function backToDraft(): void { $pr = $this->findAdminPR($this->id); app(PressReleaseService::class)->backToDraft($pr); $this->currentStatus = PressReleaseStatus::Draft->value; Flux::toast(text: __('Zurück auf Entwurf gesetzt.'), variant: 'success'); } public function archive(): void { $pr = $this->findAdminPR($this->id); app(PressReleaseService::class)->archive($pr); $this->currentStatus = PressReleaseStatus::Archived->value; $this->targetStatus = $this->currentStatus; Flux::toast(text: __('Pressemitteilung archiviert.'), variant: 'success'); } public function changeStatus(): void { $this->validate([ 'targetStatus' => ['required', Rule::in(array_map(fn(PressReleaseStatus $status) => $status->value, PressReleaseStatus::cases()))], ]); if ($this->targetStatus === $this->currentStatus) { $this->addError('targetStatus', __('Bitte wähle einen anderen Status aus.')); return; } $status = PressReleaseStatus::from($this->targetStatus); $pr = $this->findAdminPR($this->id); app(PressReleaseService::class)->changeStatusFromAdmin($pr, $status); $this->currentStatus = $status->value; $this->targetStatus = $status->value; Flux::toast(text: __('Status wurde auf ":status" geändert.', ['status' => $status->label()]), variant: 'success'); Flux::modal('confirm-status-change')->close(); } public function deletePressRelease(): void { $pr = $this->findAdminPR($this->id); $wasPublished = $pr->status === PressReleaseStatus::Published; app(PressReleaseService::class)->deleteFromAdmin($pr); Flux::toast(text: $wasPublished ? __('Pressemitteilung wurde archiviert und der Inhalt durch den voreingestellten Ersatztext ersetzt.') : __('Pressemitteilung wurde gelöscht.'), variant: 'success'); $this->redirect(route('admin.press-releases.index'), navigate: true); } public function with(): array { $term = Portal::stripTrailingAbbreviation($this->companySearch); $companies = Company::withoutGlobalScopes() ->searchByTerm($term) ->when(blank($term) && $this->companyId, fn($q) => $q->whereIn('id', [(int) $this->companyId])) ->when(blank($term) && !$this->companyId, fn($q) => $q->whereRaw('0 = 1')) ->orderBy('name') ->limit(50) ->get(['id', 'name']); $statusEnum = PressReleaseStatus::tryFrom($this->currentStatus); $selectedCompany = $this->selectedCompany(); return [ 'companies' => $companies, 'categories' => $this->categoryOptions(), 'portalOptions' => array_filter(Portal::cases(), fn(Portal $p) => $p !== Portal::Both), 'statusOptions' => PressReleaseStatus::cases(), 'statusEnum' => $statusEnum, 'targetStatusEnum' => PressReleaseStatus::tryFrom($this->targetStatus), 'selectedCompany' => $selectedCompany, 'selectedCompanyContacts' => $selectedCompany ? $this->companyContacts((int) $selectedCompany->id) : Contact::query()->whereRaw('0 = 1')->get(), 'tagSuggestions' => $this->tagSuggestionsFor($selectedCompany), ]; } #[Computed] public function tags(): array { return $this->tagsArray(); } private function selectedCompany(): ?Company { return $this->companyId ? Company::withoutGlobalScopes()->find((int) $this->companyId) : null; } private function categoryOptions(): Collection { return app(AdminPerformanceCache::class)->remember(AdminPerformanceCache::ActiveCategoryOptions, AdminPerformanceCache::OptionsTtl, fn() => Category::query()->with('translations')->where('is_active', true)->orderBy('id')->get()); } }; ?>
@php $statusClass = $statusEnum?->badgeClass() ?? 'muted'; @endphp {{-- Flash-Banner ersetzt durch im Layout. --}} {{-- ============== PAGE HEADER ============== --}} {{ $statusEnum?->label() ?? $currentStatus }} ID {{ $id }} {{ __('Prüfung') }} {{ __('Vorschau / Detail') }} {{ __('Zur Liste') }} {{-- ============== KI-PRÜFUNG (On-Demand) ============== --}}
{{ __('KI-Prüfung') }} {{ __('Prüfung im Hintergrund starten') }} {{ __('Startet eine erneute KI-Prüfung. Das Ergebnis aktualisiert nur die Bewertung und das Audit-Log – der Status bleibt unverändert.') }}
{{ __('Abbrechen') }} {{ __('Prüfung starten') }}
{{-- ============== 2-COLUMN GRID ============== --}}
{{-- =================== LINKS: SCHREIBFLÄCHE =================== --}}
{{-- 1) FIRMA-SELEKTOR --}}
{{ __('Für Firma') }} * @foreach ($companies as $company) {{ $company->name }} @if ($company->portal) ({{ $company->portal->abbreviation() }}) @endif @endforeach @if (blank(trim($companySearch))) {{ __('Mindestens 1 Zeichen eingeben…') }} @else {{ __('Keine Firma gefunden.') }} @endif
{{ __('Boilerplate und Pressekontakt werden bei Wechsel angepasst.') }} @if ($selectedCompany) {{ __('Firmenprofil') }} @endif
{{-- 2) TITEL --}}
{{ __('Titel / Headline') }} *
@php $titleLen = mb_strlen($title); $titleClass = $titleLen >= 40 && $titleLen <= 90 ? 'good' : ($titleLen > 0 ? 'warn' : ''); $titleBar = min(100, max(0, ($titleLen / 100) * 100)); @endphp {{ $titleLen }} / 100 {{ __('KI-Titel · bald') }}

{{ __('40–90 Zeichen empfohlen. Konkret, ohne Marketing-Floskeln.') }}

{{-- 3) SUBTITLE --}}
{{ __('Untertitel') }} — {{ __('optional') }} @php $subLen = mb_strlen($subtitle); $subBar = min(100, max(0, ($subLen / 200) * 100)); @endphp {{ $subLen }} / 200
{{-- 4) FLIESSTEXT --}}
{{ __('Fließtext') }} *
@php $textLen = app( \App\Services\PressRelease\PressReleaseHtmlSanitizer::class, )->plainTextLength($text); $textClass = $textLen >= 600 ? 'good' : ($textLen >= 50 ? 'warn' : ''); $textBar = min(100, max(0, ($textLen / 3500) * 100)); @endphp {{ number_format($textLen, 0, ',', '.') }} / 3.500 Z. {{ __('KI-Lektorat · bald') }}
{{ __('KI-Lektorat') }} {{ __('liest Korrektur, schlägt Kürzungen vor und prüft auf werbliche Sprache. Erscheint hier inline — bald verfügbar.') }}
{{-- 5) MEDIEN --}} {{-- 6) ANHÄNGE — TEMPORÄR DEAKTIVIERT Datei-Uploads erfordern eine vollständige Sicherheitsprüfung (Virus-/Malware-Scan, MIME-Validierung, Storage-Quoten). Wird in einer späteren Phase aktiviert. --}} {{-- 7) BOILERPLATE --}}
{{ __('Über das Unternehmen') }} — {{ __('Boilerplate aus Firma') }}
@if ($selectedCompany?->boilerplate)

{!! nl2br(e($selectedCompany->boilerplate)) !!}

@if ($selectedCompany->website)

Web: {{ $selectedCompany->website }}

@endif
@else
{{ __('Für diese Firma ist noch kein Boilerplate-Text hinterlegt. Du kannst entweder einen Override-Text für diese PM setzen oder das Firmenprofil ergänzen.') }}
@endif @if ($useBoilerplateOverride)
@endif

{{ __('Wird automatisch unter jeder Pressemitteilung dieser Firma angefügt. Pro PM editierbar.') }}

{{-- /Schreibfläche --}} {{-- =================== RECHTS: SETTINGS-SIDEBAR =================== --}}
{{ __('Status wirklich wechseln?') }} {{ __('Aktuell: :current. Neuer Status: :target.', [ 'current' => $statusEnum?->label() ?? $currentStatus, 'target' => $targetStatusEnum?->label() ?? $targetStatus, ]) }}
{{ __('Abbrechen') }} {{ __('Status ändern') }}
{{ __('Pressemitteilung löschen?') }} @if ($currentStatus === 'published') {{ __('Diese Pressemitteilung ist veröffentlicht. Sie wird nicht entfernt, sondern archiviert und der Inhalt wird durch den voreingestellten Ersatztext ersetzt, damit die URL keinen 404-Fehler erzeugt.') }} @else {{ __('Diese Pressemitteilung wird per Soft Delete aus den Standardlisten entfernt.') }} @endif
{{ __('Abbrechen') }} {{ __('Löschung bestätigen') }}