components([ TextInput::make('name') ->label('Nama Lengkap') ->placeholder('John Doe') ->autocomplete(false) ->autofocus() ->required() ->maxLength(100), TextInput::make('email') ->label('Alamat Surel') ->placeholder('johndoe@example.com') ->autocomplete(false) ->required() ->maxLength(254) ->unique('users', 'email') ->email() ->prefixIcon('heroicon-o-envelope') ->aboveContent('Pastikan alamat surel aktif untuk verifikasi akun Anda.'), TextInput::make('username') ->label('Nama Pengguna') ->placeholder('johndoe') ->autocomplete(false) ->required() ->minLength(5) ->maxLength(10) ->regex('/^[a-zA-Z0-9_.-]+$/') ->unique('users', 'username') ->prefixIcon('heroicon-o-at-symbol'), TextInput::make('password') ->label('Kata Sandi') ->password() ->revealable(filament()->arePasswordsRevealable()) ->required() ->rule(Password::default()) ->autocomplete(false) ->dehydrated(fn ($state): bool => filled($state)) ->dehydrateStateUsing(fn ($state): string => Hash::make($state)) ->placeholder('********') ->prefixIcon('heroicon-o-lock-closed'), ]); } protected function handleRegistration(array $data): Model { $user = $this->getUserModel()::create($data); $user->assignRole(RoleEnum::PERUSAHAAN->value); CheerfulNotification::success( CheerfulNotification::getByKey('auth.registration.success.title'), CheerfulNotification::getByKey('auth.registration.success.body', ['name' => $user->name]) ) ->send(); $this->getUserModel()::superAdmin() ->get() ->each(function ($admin) use ($user): void { $admin->notify(new BroadcastNotification([ 'title' => CheerfulNotification::getByKey('auth.registration.admin_notify.title'), 'body' => CheerfulNotification::getByKey('auth.registration.admin_notify.body', ['name' => $user->name]), 'action' => [ Action::make('view') ->label('Lihat') ->url(PartnerResource::getUrl('view', ['record' => $user->id])), ], ])); }); return $user; } }