Deutsche Labels der geänderten Felder. */ public array $changedFieldLabels; public function __construct( public readonly User $user, public readonly PressRelease $pressRelease, public readonly LegalRequest $legalRequest, ) { $this->showUrl = $user->canAccessAdmin() ? route('admin.press-releases.show', $pressRelease->id) : route('me.press-releases.show', $pressRelease->id); $this->isPaidChange = $legalRequest->type === LegalRequestType::Change; $this->changedFieldLabels = $this->resolveChangedFieldLabels($legalRequest); $this->configureUnsubscribe($user, EmailNotificationType::PressReleaseCorrected); } public function envelope(): Envelope { $prefix = $this->isPaidChange ? 'Ihre Änderung ist live' : 'Ihre Korrektur ist live'; return new Envelope( subject: $prefix.': '.$this->pressRelease->title, ); } public function content(): Content { return new Content(view: 'emails.press-release.change-applied'); } /** * @return list */ private function resolveChangedFieldLabels(LegalRequest $legalRequest): array { $labels = [ 'title' => 'Titel', 'subtitle' => 'Untertitel', 'text' => 'Text', 'keywords' => 'Keywords', ]; return collect((array) ($legalRequest->payload['fields'] ?? [])) ->filter(fn (array $meta): bool => (bool) ($meta['changed'] ?? false)) ->keys() ->map(fn (string $field): string => $labels[$field] ?? $field) ->values() ->all(); } }