From 4b35d8ec4856bdbc426680680bfc2b1e34db6bac Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Tue, 10 Mar 2026 11:23:15 +0700 Subject: [PATCH] feat: Update admin panel configuration to include custom Profile page for user management. --- app/Filament/Pages/Profile.php | 97 +++++++++++++++++++ app/Providers/Filament/AdminPanelProvider.php | 2 + 2 files changed, 99 insertions(+) create mode 100644 app/Filament/Pages/Profile.php diff --git a/app/Filament/Pages/Profile.php b/app/Filament/Pages/Profile.php new file mode 100644 index 0000000..f85c82f --- /dev/null +++ b/app/Filament/Pages/Profile.php @@ -0,0 +1,97 @@ +components([ + Section::make('Akun') + ->schema([ + TextInput::make('email') + ->label('Alamat Surel') + ->placeholder('johndoe@puskesmas.com') + ->autocomplete(false) + ->required() + ->maxLength(254) + ->unique(ignoreRecord: true) + ->email() + ->live(), + + TextInput::make('username') + ->label('Nama Pengguna') + ->placeholder('johndoe') + ->autocomplete(false) + ->required() + ->minLength(5) + ->maxLength(20) + ->regex('/^[a-zA-Z0-9_.-]+$/') + ->unique(ignoreRecord: true), + ]), + + Section::make('Kata Sandi') + ->schema([ + TextInput::make('password') + ->label(__('filament-panels::auth/pages/register.form.password.label')) + ->placeholder('********') + ->password() + ->revealable(filament()->arePasswordsRevealable()) + ->required(fn (Get $get) => filled($get('passwoed')) || filled($get('passwordConfirmation'))) + ->rule(Password::default()) + ->showAllValidationMessages() + ->dehydrateStateUsing(fn ($state) => Hash::make($state)) + ->same('passwordConfirmation') + ->validationAttribute(__('filament-panels::auth/pages/register.form.password.validation_attribute')), + + TextInput::make('passwordConfirmation') + ->label(__('filament-panels::auth/pages/register.form.password_confirmation.label')) + ->placeholder('********') + ->password() + ->revealable(filament()->arePasswordsRevealable()) + ->required(fn (Get $get) => filled($get('passwoed')) || filled($get('passwordConfirmation'))) + ->dehydrated(false), + ]), + ]); + } + + protected function handleRecordUpdate(Model $record, array $data): Model + { + $shouldLogout = false; + if (isset($data['new_password'])) { + $data['password'] = $data['new_password']; + unset($data['new_password']); + $shouldLogout = true; + } + + $record->update($data); + + SystemNotification::success( + 'Profil Berhasil Diperbarui ✅', + 'Data profil Anda telah berhasil disimpan dan diperbarui di dalam sistem.' + )->send(); + + if ($shouldLogout) { + auth()->logout(); + } + + return $record; + } + + protected function getSavedNotification(): ?Notification + { + return null; + } +} diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index 191b47d..86f0f61 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -3,6 +3,7 @@ namespace App\Providers\Filament; use App\Filament\Pages\Auth\Login; +use App\Filament\Pages\Profile; use DiogoGPinto\AuthUIEnhancer\AuthUIEnhancerPlugin; use Filament\Http\Middleware\Authenticate; use Filament\Http\Middleware\AuthenticateSession; @@ -34,6 +35,7 @@ public function panel(Panel $panel): Panel ->path('admin') ->viteTheme('resources/css/filament/admin/theme.css') ->login(Login::class) + ->profile(Profile::class) ->colors([ 'primary' => Color::Gray, ])