companyId = $id; $company = Company::query()->find($id); if (! $company) { session()->flash('error', __('Die angeforderte Firma wurde nicht gefunden.')); $this->redirect(route('admin.companies.index'), navigate: true); return; } $this->portal = $company->portal?->value ?? Portal::Both->value; $this->allowBothPortal = $company->portal === Portal::Both || $company->portal === null; $this->company_name = $company->name; $this->description = ''; $this->email = $company->email ?? ''; $this->phone = $company->phone ?? ''; $this->website = $company->website ?? ''; $this->street = $company->address ?? ''; $this->zip = ''; $this->city = ''; $this->state = ''; $this->country = $company->country_code ?? 'DE'; $this->is_verified = false; $this->is_active = (bool) $company->is_active; $this->goneAt = $company->gone_at?->format('d.m.Y H:i'); $this->current_logo_url = $company->logoUrl(); } public function update(ImageService $imageService): void { $this->authorize('companies:write'); $this->validate(); $company = Company::query()->find($this->companyId); if (! $company) { session()->flash('error', __('Die angeforderte Firma wurde nicht gefunden.')); $this->redirect(route('admin.companies.index'), navigate: true); return; } $allowedPortals = [Portal::Presseecho->value, Portal::Businessportal24->value]; if ($company->portal === Portal::Both || $company->portal === null) { $allowedPortals[] = Portal::Both->value; } if (! in_array($this->portal, $allowedPortals, true)) { throw ValidationException::withMessages([ 'portal' => __('„Beide Portale" kann nicht mehr neu zugewiesen werden.'), ]); } $slug = $company->generateUniqueSlug($this->company_name, ['portal' => $this->portal]); $previousLogoPath = $company->logo_path; $previousLogoVariants = $company->logo_variants; $logoPath = $previousLogoPath; $logoVariants = $previousLogoVariants; $discardPreviousLogo = false; $stored = null; if ($this->remove_logo) { $logoPath = null; $logoVariants = null; $discardPreviousLogo = true; } if ($this->logo) { // Erst die neue Datei speichern, dann die DB-Referenz wechseln, das // alte Logo erst danach löschen: Scheitert der Storage, bleiben // bisheriges Logo und Datensatz unangetastet (F23). try { $stored = $imageService->storeCompanyLogo( $this->logo, $this->portal === Portal::Both->value ? Portal::Presseecho->value : $this->portal, $company->id, ); } catch (\RuntimeException $exception) { report($exception); throw ValidationException::withMessages([ 'logo' => __('Das Logo konnte nicht gespeichert werden. Bitte versuchen Sie es erneut.'), ]); } $logoPath = $stored['path']; $logoVariants = $stored['variants']; $discardPreviousLogo = true; } try { $company->update([ 'portal' => $this->portal, 'name' => $this->company_name, 'slug' => $slug, 'address' => $this->composeAddress(), 'country_code' => strtoupper($this->country), 'phone' => $this->phone ?: null, 'email' => $this->email ?: null, 'website' => $this->website ?: null, 'logo_path' => $logoPath, 'logo_variants' => $logoVariants, 'is_active' => $this->is_active, ]); } catch (\Throwable $exception) { // Ohne DB-Referenz wäre die neue Datei verwaist. if ($stored !== null) { $imageService->deleteCompanyLogo($stored['path'], $stored['variants']); } throw $exception; } if ($discardPreviousLogo && $previousLogoPath !== null && $previousLogoPath !== $logoPath) { $imageService->deleteCompanyLogo($previousLogoPath, $previousLogoVariants); } session()->flash('success', 'Firma erfolgreich aktualisiert.'); $this->redirect(route('admin.companies.index'), navigate: true); } public function with(): array { return [ 'countries' => collect([ ['code' => 'DE', 'name' => 'Deutschland'], ['code' => 'AT', 'name' => 'Österreich'], ['code' => 'CH', 'name' => 'Schweiz'], ['code' => 'FR', 'name' => 'Frankreich'], ['code' => 'GB', 'name' => 'Großbritannien'], ['code' => 'US', 'name' => 'USA'], ]), 'portalOptions' => array_filter( Portal::cases(), fn (Portal $portalCase): bool => $portalCase !== Portal::Both || $this->allowBothPortal, ), ]; } /** * Entfernung mit 410 statt Löschung: die Newsroom-URL liefert danach einen * Tombstone (410 Gone) statt eines 404. Umkehrbar über restoreGone(). */ public function markGone(CompanyRemovalService $removal): void { $this->authorize('companies:write'); $company = Company::query()->find($this->companyId); if (! $company) { session()->flash('error', __('Die angeforderte Firma wurde nicht gefunden.')); $this->redirect(route('admin.companies.index'), navigate: true); return; } $affected = $removal->markGone($company, $this->goneIncludesPressReleases); session()->flash('success', $affected > 0 ? __('Newsroom mit 410 entfernt — inklusive :count Pressemitteilung(en).', ['count' => $affected]) : __('Newsroom mit 410 entfernt. Die URL liefert jetzt 410 Gone.')); $this->redirect(route('admin.companies.index'), navigate: true); } public function restoreGone(CompanyRemovalService $removal): void { $this->authorize('companies:write'); $company = Company::query()->find($this->companyId); if (! $company) { session()->flash('error', __('Die angeforderte Firma wurde nicht gefunden.')); $this->redirect(route('admin.companies.index'), navigate: true); return; } $removal->restoreFromGone($company); session()->flash('success', __('410-Entfernung aufgehoben. Bereits entfernte Pressemitteilungen bleiben entfernt.')); $this->redirect(route('admin.companies.edit', $this->companyId), navigate: true); } public function deleteCompany(): void { $this->authorize('companies:write'); $company = Company::query()->find($this->companyId); if (! $company) { session()->flash('error', __('Die angeforderte Firma wurde nicht gefunden.')); $this->redirect(route('admin.companies.index'), navigate: true); return; } $company->delete(); session()->flash('success', __('Firma wurde erfolgreich gelöscht.')); $this->redirect(route('admin.companies.index'), navigate: true); } protected function composeAddress(): ?string { $lineOne = trim($this->street); $lineTwo = trim(trim($this->zip).' '.trim($this->city)); $lineThree = trim($this->state); $parts = array_filter([$lineOne, $lineTwo, $lineThree], fn ($value) => $value !== ''); return $parts !== [] ? implode(', ', $parts) : null; } }; ?>
{{-- ============== PAGE HEADER ============== --}} ID {{ $companyId }} {{ __('Zurück') }}
{{ __('Basisinformationen') }}
{{ __('Portal') }} @foreach ($portalOptions as $portalOption) @endforeach {{ __('Firmenname') }} * {{ __('Beschreibung') }}
{{ __('E-Mail') }} * {{ __('Telefon') }}
{{ __('Website') }}
{{ __('Adresse') }}
{{ __('Straße & Hausnummer') }}
{{ __('PLZ') }} {{ __('Stadt') }}
{{ __('Bundesland / Region') }} {{ __('Land') }} * @foreach ($countries as $country) @endforeach
{{ __('Rechtliche Daten') }}
{{ __('Steuernummer / USt-IdNr.') }} {{ __('Handelsregisternummer') }}
{{ __('Logo & Status') }}
{{ __('Firmenlogo') }} {{ __('Maximal 4 MB. Varianten (sq/wide) werden automatisch generiert.') }} @if ($logo)
{{ __('Neues Logo (Vorschau):') }}
@elseif ($current_logo_url && ! $remove_logo)
{{ __('Aktuelles Logo:') }}
{{ __('Logo entfernen') }}
@elseif ($remove_logo)
{{ __('Logo wird beim Speichern entfernt.') }}
{{ __('Rückgängig') }}
@endif
{{ __('Aktionen') }}
@if ($goneAt)
{{ __('Dieser Newsroom ist mit 410 entfernt (seit :date). Die öffentliche Newsroom-URL liefert einen Tombstone statt Inhalten.', ['date' => $goneAt]) }}
@endif
@if ($goneAt) {{ __('410-Entfernung aufheben') }} @else {{ __('Entfernen mit 410') }} @endif {{ __('Vollständig löschen') }}
{{ __('Abbrechen') }} {{ __('Änderungen speichern') }}
{{ __('Newsroom mit 410 entfernen?') }} {{ __('Der Newsroom wird deaktiviert und verschwindet aus Newsroom-Übersicht und Sitemap. Seine bestehende URL antwortet danach mit „410 Gone“ und zeigt einen Hinweis auf die Entfernung — statt eines 404. Die Firma bleibt in der Verwaltung erhalten, die Entfernung ist umkehrbar.') }}
{{ __('Abbrechen') }} {{ __('Mit 410 entfernen') }}
{{ __('Firma wirklich löschen?') }} {{ __('Diese Aktion kann nicht direkt rückgängig gemacht werden. Die Firma wird archiviert (Soft Delete) und aus den Standardlisten entfernt. Die öffentliche Newsroom-URL antwortet danach mit 404. Soll die Adresse stattdessen einen Entfernungs-Hinweis mit „410 Gone“ ausliefern, brechen Sie hier ab und wählen „Entfernen mit 410“.') }}
{{ __('Abbrechen') }} {{ __('Löschung bestätigen') }}