loadRoleOptions(); } private function loadRoleOptions(): void { $roles = Role::whereNotNull('reg_prefix')->where('can_be_invited', true)->orderBy('id', 'asc')->get(); foreach ($roles as $role) { $key = strtolower(str_replace('-', '', $role->name)); $slug = strtolower($role->reg_prefix); $this->roleOptions[$key] = [ 'label' => $role->display_name ?? $role->name, 'prefix' => $role->reg_prefix, 'slug' => $slug, 'color' => $role->color ?? 'zinc', 'icon' => $role->icon ?? 'key', ]; } if (!empty($this->roleOptions)) { $this->selectedRole = array_key_first($this->roleOptions); } } public function with(): array { // Lade verfügbare Codes für ausgewählte Rolle $availableCodes = RegistrationCode::where('role', $this->selectedRole) ->where('status', RegistrationCode::STATUS_AVAILABLE) ->orderBy('created_at', 'desc') ->take(10) ->get(); // Lade letzte verwendete Codes $recentUsedCodes = RegistrationCode::where('status', RegistrationCode::STATUS_USED) ->with('usedBy') ->orderBy('used_at', 'desc') ->take(5) ->get(); return [ 'roleOptions' => $this->roleOptions, 'availableCodes' => $availableCodes, 'recentUsedCodes' => $recentUsedCodes, ]; } }; ?>