id = $id; if (! User::query()->whereKey($id)->exists()) { session()->flash('error', __('Der angeforderte Benutzer wurde nicht gefunden.')); $this->redirect(route('admin.users.index'), navigate: true); return; } } public function companyUserRoleLabel(?string $role): string { return match ($role ?? 'member') { 'owner' => __('Inhaber'), 'responsible' => __('Verantwortlich'), 'member' => __('Mitglied'), default => (string) ($role ?? 'member'), }; } public function with(): array { $user = User::query() ->with([ 'roles' => fn ($query) => $query->orderBy('name'), 'companies' => fn ($query) => $query ->select(['companies.id', 'companies.name', 'companies.slug', 'companies.email', 'companies.phone', 'companies.portal', 'companies.is_active']) ->withCount('contacts') ->orderBy('name'), 'companies.contacts' => fn ($query) => $query ->select(['contacts.id', 'contacts.company_id', 'contacts.portal', 'contacts.first_name', 'contacts.last_name', 'contacts.responsibility', 'contacts.email', 'contacts.phone']) ->orderBy('last_name') ->orderBy('first_name') ->limit(10), 'billingAddress', ]) ->find($this->id); return [ 'user' => $user, ]; } }; ?>
@if (!$user) {{ __('Benutzer nicht gefunden') }} {{ __('Zurück zur Übersicht') }} @else
{{ $user->name }} {{ $user->email }} ID: {{ $user->id }}
{{ __('Zurück') }} {{ __('Bearbeiten') }}
{{ __('Portal') }} {{ $user->portal?->label() ?? '-' }} {{ __('Typ') }} {{ $user->registration_type?->label() ?? '-' }} {{ __('Status') }} @if ($user->is_active) {{ __('Aktiv') }} @else {{ __('Inaktiv') }} @endif {{ __('Letzter Login') }} {{ $user->last_login_at?->format('d.m.Y H:i') ?? __('Nie') }} @if ($user->last_login_ip) {{ $user->last_login_ip }} @endif
{{ __('Rollen') }}
@forelse($user->roles as $role) {{ $role->name }} @empty {{ __('Keine Rollen hinterlegt') }} @endforelse
{{ __('Rechnungsadresse') }} @if ($user->billingAddress)
{{ $user->billingAddress->name }} {{ $user->billingAddress->address1 }} @if ($user->billingAddress->address2) {{ $user->billingAddress->address2 }} @endif {{ $user->billingAddress->postal_code }} {{ $user->billingAddress->city }} {{ $user->billingAddress->country_code }}
@else {{ __('Keine Rechnungsadresse hinterlegt') }} @endif
{{ __('Verknüpfte Firmen und Kontakte') }} {{ __('Kontakte sind die Ansprechpartner der verknüpften Firmen (wie in der Bearbeiten-Ansicht).') }}
@forelse($user->companies as $company)
@if (\Illuminate\Support\Facades\Route::has('admin.companies.show')) {{ $company->name }} @else {{ $company->name }} @endif {{ $company->slug }}
@if ($company->email) {{ $company->email }} @endif @if ($company->phone) {{ $company->phone }} @endif
{{ $this->companyUserRoleLabel($company->pivot?->role ?? 'member') }} {{ $company->portal?->label() ?? '—' }} @if (!$company->is_active) {{ __('Inaktiv') }} @endif
@if ($company->contacts->isNotEmpty())
@foreach ($company->contacts as $contact)
{{ trim(($contact->first_name ?? '') . ' ' . ($contact->last_name ?? '')) ?: __('Kontakt ohne Name') }} {{ $contact->responsibility ?? __('Keine Rolle hinterlegt') }}
@if ($contact->email) {{ $contact->email }} @endif @if ($contact->phone) {{ $contact->phone }} @endif
{{ $contact->portal?->label() ?? '—' }} @if (\Illuminate\Support\Facades\Route::has('admin.contacts.edit')) {{ __('Bearbeiten') }} @endif
@endforeach @if ($company->contacts_count > $company->contacts->count()) {{ __(':count weitere Kontakte werden hier nicht geladen. Öffne die Firma, um alle Kontakte zu sehen.', ['count' => $company->contacts_count - $company->contacts->count()]) }} @endif
@else {{ __('Keine Kontakte bei dieser Firma') }} @endif
@empty {{ __('Keine Firmen verknüpft') }} @endforelse
@endif