{{ __('registration.titles.registration') }}
{{ __('registration.titles.access_for_role', ['role' => $roleLabel]) }}
{{ $roleDescription }}
loadRoleMap(); $slug = strtolower($role); if (!isset($this->roleMap[$slug])) { abort(404); } $this->roleSlug = $slug; $this->roleKey = $this->roleMap[$slug]['key']; $this->roleLabel = $this->roleMap[$slug]['label']; $this->roleDescription = $this->roleMap[$slug]['description']; $this->codePrefix = $this->roleMap[$slug]['prefix'] ?? ''; } protected function loadRoleMap(): void { if (!empty($this->roleMap)) { return; } $roles = Role::whereNotNull('reg_prefix')->where('can_be_invited', true)->get(); foreach ($roles as $role) { $slug = strtolower(str_replace('-', '', $role->reg_prefix)); $key = strtolower(str_replace('-', '', $role->name)); $this->roleMap[$slug] = [ 'key' => $key, 'label' => __('registration.roles.' . $key . '.label'), 'description' => __('registration.roles.' . $key . '.description'), 'prefix' => $role->reg_prefix, ]; } } public function submitCode(): void { $this->validate([ 'codePrefix' => ['required', 'string', 'size:1'], 'codePart1' => ['required', 'digits:2'], 'codePart2' => ['required', 'digits:2'], 'codePart3' => ['required', 'digits:2'], 'codePart4' => ['required', 'digits:2'], ]); $normalized = $this->normalizeCode( $this->codePrefix, $this->codePart1, $this->codePart2, $this->codePart3, $this->codePart4 ); /** @var RegistrationCode|null $registrationCode */ $registrationCode = RegistrationCode::where('code', $normalized) ->where('role', $this->roleKey) ->first(); if (!$registrationCode || !$registrationCode->isAvailable()) { $this->addError('code', __('registration.messages.code_invalid')); return; } // Merke Code in Session; Verbrauch/Markierung erfolgt nach erfolgreicher Registrierung. session([ 'registration_code_id' => $registrationCode->id, 'registration_role' => $this->roleKey, 'registration_slug' => $this->roleSlug, ]); session()->flash('message', __('registration.messages.code_accepted')); $this->redirect(route('partner.create.account'), navigate: true); } protected function normalizeCode(string $prefix, string ...$parts): string { $prefix = strtoupper(trim($prefix)); $segments = array_map(fn ($p) => str_pad(preg_replace('/\D+/', '', $p), 2, '0', STR_PAD_LEFT), $parts); return $prefix . implode('', $segments); } }; ?>
{{ __('registration.titles.registration') }}
{{ $roleDescription }}