*/ protected function userIdentityRules(?int $ignoreUserId = null): array { $emailUnique = Rule::unique('users', 'email'); if ($ignoreUserId !== null) { $emailUnique = $emailUnique->ignore($ignoreUserId); } return [ 'name' => ['required', 'string', 'max:255'], 'agencyName' => ['nullable', 'string', 'max:190'], 'email' => ['required', 'email', $emailUnique], 'portal' => ['required', Rule::in(array_map(static fn (Portal $portal): string => $portal->value, Portal::cases()))], 'registrationType' => ['required', Rule::in(array_map(static fn (RegistrationType $type): string => $type->value, RegistrationType::cases()))], 'language' => ['required', 'string', Rule::in(['de', 'en'])], ]; } /** * Rollen-Auswahl plus Firmen-Verknüpfungen mit Pivot-Rolle. * * @return array */ protected function userRolesAndCompaniesRules(): array { return [ 'selectedRoles' => ['required', 'array', 'min:1'], 'selectedRoles.*' => ['string', Rule::exists('roles', 'name')], 'linkedCompanyIds' => ['array'], 'linkedCompanyIds.*' => ['integer', Rule::exists('companies', 'id')], 'companyRoles' => ['array'], 'companyRoles.*' => ['string', Rule::in(['member', 'responsible', 'owner'])], ]; } /** * Rechnungsadresse (optional; nur gespeichert, wenn vollständig). * * @return array */ protected function userBillingRules(): array { return [ 'billing.salutation_key' => ['nullable', 'string', 'max:20'], 'billing.title' => ['nullable', 'string', 'max:80'], 'billing.name' => ['nullable', 'string', 'max:255'], 'billing.address1' => ['nullable', 'string', 'max:255'], 'billing.address2' => ['nullable', 'string', 'max:255'], 'billing.postal_code' => ['nullable', 'string', 'max:20'], 'billing.city' => ['nullable', 'string', 'max:120'], 'billing.country_code' => ['nullable', 'string', 'size:2'], ]; } }