user(); $profile = $user->profile; $this->name = (string) $user->name; $this->language = $user->language ?? 'de'; $this->salutationKey = (string) ($profile?->salutation_key ?? 'none'); $this->firstName = (string) ($profile?->first_name ?? ''); $this->lastName = (string) ($profile?->last_name ?? ''); $this->title = (string) ($profile?->title ?? ''); $this->phone = (string) ($profile?->phone ?? ''); $this->address = (string) ($profile?->address ?? ''); $this->countryCode = (string) ($profile?->country_code ?? 'DE'); $this->backlinkUrl = (string) ($profile?->backlink_url ?? ''); $this->showStats = (bool) ($profile?->show_stats ?? false); $this->disableFooterCode = (bool) ($profile?->disable_footer_code ?? false); $this->taxIdNumber = (string) ($profile?->tax_id_number ?? ''); $billingAddress = $user->billingAddress; $this->billingName = (string) ($billingAddress?->name ?? ''); $this->billingAddress1 = (string) ($billingAddress?->address1 ?? ''); $this->billingAddress2 = (string) ($billingAddress?->address2 ?? ''); $this->billingPostalCode = (string) ($billingAddress?->postal_code ?? ''); $this->billingCity = (string) ($billingAddress?->city ?? ''); $this->billingCountryCode = (string) ($billingAddress?->country_code ?? 'DE'); } public function saveProfile(): void { $validated = $this->validate([ 'name' => ['required', 'string', 'max:120'], 'language' => ['required', Rule::in(['de', 'en'])], 'salutationKey' => ['required', Rule::in(array_keys((array) config('salutations.items', [])))], 'firstName' => ['nullable', 'string', 'max:80'], 'lastName' => ['nullable', 'string', 'max:80'], 'title' => ['nullable', 'string', 'max:80'], 'phone' => ['nullable', 'string', 'max:40'], 'address' => ['nullable', 'string', 'max:1000'], 'countryCode' => ['nullable', 'string', 'size:2', Rule::in(array_keys((array) config('countries.items', [])))], 'backlinkUrl' => ['nullable', 'url', 'max:255'], 'taxIdNumber' => ['nullable', 'string', 'max:255'], 'billingName' => ['nullable', 'string', 'max:255'], 'billingAddress1' => ['nullable', 'string', 'max:255'], 'billingAddress2' => ['nullable', 'string', 'max:255'], 'billingPostalCode' => ['nullable', 'string', 'max:20'], 'billingCity' => ['nullable', 'string', 'max:120'], 'billingCountryCode' => ['nullable', 'string', 'size:2', Rule::in(array_keys((array) config('countries.items', [])))], ]); if ($this->billingHasInput() && ! $this->billingIsComplete()) { throw ValidationException::withMessages([ 'billingName' => __('Bitte füllen Sie für eine Rechnungsadresse Name, Adresse, PLZ, Ort und Land aus.'), ]); } /** @var User $user */ $user = auth()->user(); $user->forceFill([ 'name' => $validated['name'], 'language' => $validated['language'], ])->save(); $user->profile()->updateOrCreate( ['user_id' => $user->id], [ 'salutation_key' => $validated['salutationKey'], 'first_name' => $validated['firstName'] ?: null, 'last_name' => $validated['lastName'] ?: null, 'title' => $validated['title'] ?: null, 'phone' => $validated['phone'] ?: null, 'address' => $validated['address'] ?: null, 'country_code' => $validated['countryCode'] ?: null, 'backlink_url' => $validated['backlinkUrl'] ?: null, 'show_stats' => $this->showStats, 'disable_footer_code' => $this->disableFooterCode, 'tax_id_number' => $validated['taxIdNumber'] ?: null, ] ); if (! $this->billingHasInput()) { $user->billingAddress()->delete(); } else { $user->billingAddress()->updateOrCreate( ['user_id' => $user->id], [ 'salutation_key' => $validated['salutationKey'] !== 'none' ? $validated['salutationKey'] : null, 'title' => $validated['title'] ?: null, 'name' => $validated['billingName'], 'address1' => $validated['billingAddress1'], 'address2' => $validated['billingAddress2'] ?: null, 'postal_code' => $validated['billingPostalCode'], 'city' => $validated['billingCity'], 'country_code' => $validated['billingCountryCode'], // USt-ID auch an der Rechnungsadresse pflegen — sie wird // pro Rechnung eingefroren und bestimmt die Steuer // (EU-Befreiung nur mit gültiger USt-ID). 'vat_id' => $validated['taxIdNumber'] ?: null, ], ); } session()->flash('profile-status', __('Profil gespeichert.')); } public function with(): array { $user = auth()->user(); return [ 'user' => $user, 'salutations' => collect((array) config('salutations.items', [])) ->map(fn (array $labels) => $labels[$user->language] ?? $labels['de'] ?? '') ->all(), 'countries' => (array) config('countries.items', []), 'billingComplete' => $this->billingIsComplete(), ]; } public function billingHasInput(): bool { return filled($this->billingName) || filled($this->billingAddress1) || filled($this->billingAddress2) || filled($this->billingPostalCode) || filled($this->billingCity); } public function billingIsComplete(): bool { return filled($this->billingName) && filled($this->billingAddress1) && filled($this->billingPostalCode) && filled($this->billingCity) && filled($this->billingCountryCode); } }; ?>
{{-- ============== PAGE HEADER ============== --}} @if (session('profile-status'))
{{ session('profile-status') }}
@endif
{{ __('Rechnungsadresse') }} @if ($billingComplete) {{ __('vollständig') }} @else {{ __('unvollständig') }} @endif

{{ __('Diese Adresse ist die maßgebliche Grundlage für Rechnungen und künftige Buchungen.') }}

{{ __('Pflichtangaben sind Rechnungsname, Adresse, PLZ, Ort und Land. Die USt-ID ist optional.') }}

@if (! $billingComplete)
{{ __('Bitte ergänzen Sie die Rechnungsadresse, damit neue Buchungen sauber abgerechnet werden können.') }}
@else
{{ __('Ihre Rechnungsadresse ist vollständig hinterlegt.') }}
@endif
@foreach ($countries as $code => $name) @endforeach
{{ __('Rechnungsadresse speichern') }}
{{ __('Profileinstellungen') }}
@foreach ($salutations as $key => $label) @endforeach @foreach ($countries as $code => $name) @endforeach
{{ __('Profil speichern') }}
{{ __('Konto & Sicherheit') }}
{{ __('Konto-Sicherheit öffnen') }}
{{ __('Einstellungen') }}
{{ __('Einstellungen speichern') }}