countryCode = (string) config('countries.default', 'DE'); } public function save(): void { try { $validated = $this->validate([ 'name' => ['required', 'string', 'max:255', app(NoPromotionalText::class)], // „Beide Portale" ist bei der Firmen-Anlage bewusst nicht // wählbar: PMs übernehmen das Portal der Firma und würden // sonst automatisch auf beiden Portalen veröffentlicht. 'portal' => ['required', Rule::in([ Portal::Presseecho->value, Portal::Businessportal24->value, ])], 'address' => ['nullable', 'string', 'max:1000', app(NoPromotionalText::class)], 'email' => ['nullable', 'email', 'max:190'], 'phone' => ['nullable', 'string', 'max:40'], 'website' => ['nullable', 'url', 'max:190'], 'countryCode' => ['nullable', 'string', 'size:2', Rule::in(array_keys((array) config('countries.items', [])))], ]); } catch (ValidationException $e) { $count = array_sum(array_map('count', $e->errors())); Flux::toast( heading: __('Bitte Eingaben prüfen'), text: $count > 1 ? __(':count Felder benötigen deine Aufmerksamkeit.', ['count' => $count]) : __('Ein Feld benötigt deine Aufmerksamkeit.'), variant: 'danger', duration: 6000, ); throw $e; } $user = auth()->user(); $company = new Company([ 'portal' => $validated['portal'], 'owner_user_id' => $user->id, // Firmen sind ausschließlich Newsrooms; der Übermittler // („Agentur") ist eine Profil-Eigenschaft des Accounts. 'type' => CompanyType::Company->value, 'name' => $validated['name'], 'address' => $validated['address'] ?: null, 'country_code' => $validated['countryCode'] ?: null, 'email' => $validated['email'] ?: null, 'phone' => $validated['phone'] ?: null, 'website' => $validated['website'] ?: null, 'is_active' => true, 'disable_footer_code' => $this->disableFooterCode, ]); $company->slug = $company->generateUniqueSlug($validated['name'], [ 'portal' => $validated['portal'], ]); $company->save(); $user->companies()->syncWithoutDetaching([ $company->id => ['role' => 'owner'], ]); Flux::toast( heading: __('Firma angelegt'), text: __('„:name" wurde angelegt und steht sofort zur Verfügung.', ['name' => $company->name]), variant: 'success', ); $this->redirect(route('me.press-kits.show', $company->id), navigate: true); } public function with(): array { return [ 'portals' => [ Portal::Presseecho->value => Portal::Presseecho->label(), Portal::Businessportal24->value => Portal::Businessportal24->label(), ], 'countries' => (array) config('countries.items', []), ]; } }; ?>
{{-- ============== PAGE HEADER ============== --}}
{{ __('Stammdaten') }}
@foreach ($portals as $value => $label) {{ $label }} @endforeach @foreach ($countries as $code => $countryName) {{ $countryName }} @endforeach
{{ __('Abbrechen') }} {{ __('Firma anlegen') }}