selectedCompanyId(auth()->user()); $this->activeCompany = $companyId === null ? 'all' : (string) $companyId; } public function updatedActiveCompany(CustomerCompanyContext $context): void { if ($this->activeCompany === 'all') { $context->select(auth()->user(), null); } elseif (is_numeric($this->activeCompany)) { $context->select(auth()->user(), (int) $this->activeCompany); } $this->redirect($this->redirectTarget(), navigate: false); } public function with(CustomerCompanyContext $context): array { $user = auth()->user(); $selectedCompanyId = $context->selectedCompanyId($user); $companies = $context->switcherCompaniesFor($user, $selectedCompanyId, 51); $visibleCompanies = $companies->take(50)->values(); return [ 'companies' => $visibleCompanies, 'hasMoreCompanies' => $companies->count() > 50, 'selectedCompany' => $selectedCompanyId === null ? null : $visibleCompanies->firstWhere('id', $selectedCompanyId), 'context' => $context, 'user' => $user, ]; } private function redirectTarget(): string { return (string) request()->headers->get('referer', route('me.dashboard')); } }; ?>
@if ($companies->isNotEmpty())
@foreach ($companies as $company) @endforeach @if ($hasMoreCompanies) @endif
@if ($selectedCompany) {{ __('Firma öffnen') }} @else {{ __('Firmen') }} @endif @else {{ __('Keine Firma zugeordnet') }} @endif