validate(); $slug = (new Company)->generateUniqueSlug($this->company_name, ['portal' => $this->portal]); $logoPath = $this->logo ? $this->logo->store('company-logos', 'public') : null; Company::query()->create([ '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, 'is_active' => $this->is_active, ]); session()->flash('success', 'Firma erfolgreich erstellt.'); $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(), ]; } 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 · Neue Firma') }}

{{ __('Neue Firma') }}

{{ __('Stammdaten, Adresse, Logo und Rechtsangaben einer neuen Firma erfassen.') }}

{{ __('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 1 MB. Empfohlen: quadratisch, min. 400x400px') }} @if ($logo)
{{ __('Vorschau:') }}
@endif
{{ __('Aktionen') }}
{{ __('Abbrechen') }} {{ __('Firma erstellen') }}