whereIn('dominio', $candidateKeys) ->get() ->keyBy('dominio'); $tenant = collect($candidateKeys) ->map(fn (string $candidate): ?Tenant => $tenantsByDomain->get($candidate)) ->first(fn (?Tenant $candidate): bool => $candidate !== null); if (! $tenant instanceof Tenant) { throw (new ModelNotFoundException)->setModel(Tenant::class); } return $this->tenantInformationService->load( $tenant, [ 'menues' => fn ($query) => $query->whereHas( 'roles', fn ($query) => $query->where('codigo', RoleCode::User->value) ), 'categories' => fn ($query) => $query->orderBy('nombre'), ] ); } }