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->type = $company->type?->value ?? CompanyType::Company->value; $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->current_logo_url = $company->logoUrl(); } public function update(ImageService $imageService): void { $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; } $slug = $company->generateUniqueSlug($this->company_name, ['portal' => $this->portal]); $logoPath = $company->logo_path; $logoVariants = $company->logo_variants; if ($this->remove_logo) { $imageService->deleteCompanyLogo($company->logo_path, $company->logo_variants); $logoPath = null; $logoVariants = null; } if ($this->logo) { $imageService->deleteCompanyLogo($logoPath, $logoVariants); $stored = $imageService->storeCompanyLogo( $this->logo, $this->portal === Portal::Both->value ? Portal::Presseecho->value : $this->portal, $company->id, ); $logoPath = $stored['path']; $logoVariants = $stored['variants']; } $company->update([ 'portal' => $this->portal, 'type' => $this->type, '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, ]); 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' => Portal::cases(), 'typeOptions' => CompanyType::cases(), ]; } public function deleteCompany(): void { $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 ============== --}}
{{ __('Admin Backend') }} {{ __('Stammdaten · Firma bearbeiten') }} ID {{ $companyId }}

{{ __('Firma bearbeiten') }}

{{ __('Stammdaten, Adresse, Logo und Rechtsangaben der Firma aktualisieren.') }}

{{ __('Zurück') }}
{{ __('Basisinformationen') }}
{{ __('Portal') }} @foreach ($portalOptions as $portalOption) @endforeach {{ __('Typ') }} @foreach ($typeOptions as $typeOption) @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') }}
{{ __('Löschen') }}
{{ __('Abbrechen') }} {{ __('Änderungen speichern') }}
{{ __('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.') }}
{{ __('Abbrechen') }} {{ __('Löschung bestätigen') }}