From 4c0daeb09eb3e6602fc3dfd0cf3b9374ecf7fc04 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Sun, 29 Mar 2026 20:48:58 +0700 Subject: [PATCH] feat: Add Change Password action for students, including a modal for password input and success notification upon update. Update date display format in student form and improve code readability in StudentsTable. --- .../Students/Actions/ChangePasswordAction.php | 43 +++++++++++++++++++ .../Master/Students/Schemas/StudentForm.php | 2 +- .../Master/Students/Tables/StudentsTable.php | 3 ++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 app/Filament/Resources/Master/Students/Actions/ChangePasswordAction.php diff --git a/app/Filament/Resources/Master/Students/Actions/ChangePasswordAction.php b/app/Filament/Resources/Master/Students/Actions/ChangePasswordAction.php new file mode 100644 index 0000000..52dc8f1 --- /dev/null +++ b/app/Filament/Resources/Master/Students/Actions/ChangePasswordAction.php @@ -0,0 +1,43 @@ +label('Ganti Kata Sandi') + ->icon(Heroicon::OutlinedKey) + ->color('warning') + ->modalWidth(Width::Medium) + ->schema([ + TextInput::make('password') + ->label('Kata Sandi Baru') + ->password() + ->required() + ->minLength(8) + ->revealable(filament()->arePasswordsRevealable()) + ->default('Minimal8@'), + ]) + ->action(function (Student $record, array $data): void { + $record->user?->update([ + 'password' => Hash::make($data['password']), + ]); + + SystemNotification::success( + 'Kata sandi berhasil diubah! 🔑', + "Kata sandi untuk mahasiswa {$record->full_name} telah diperbarui." + )->send(); + }); + } +} diff --git a/app/Filament/Resources/Master/Students/Schemas/StudentForm.php b/app/Filament/Resources/Master/Students/Schemas/StudentForm.php index a01ddc8..ae55892 100644 --- a/app/Filament/Resources/Master/Students/Schemas/StudentForm.php +++ b/app/Filament/Resources/Master/Students/Schemas/StudentForm.php @@ -98,7 +98,7 @@ public static function configure(Schema $schema): Schema ->placeholder('Pilih Tanggal') ->required() ->native(false) - ->displayFormat('l, d F Y') + ->displayFormat('d F Y') ->maxDate(Carbon::now()->subYears(15)), TextInput::make('place_of_birth') diff --git a/app/Filament/Resources/Master/Students/Tables/StudentsTable.php b/app/Filament/Resources/Master/Students/Tables/StudentsTable.php index 4482d08..5466085 100644 --- a/app/Filament/Resources/Master/Students/Tables/StudentsTable.php +++ b/app/Filament/Resources/Master/Students/Tables/StudentsTable.php @@ -10,6 +10,7 @@ use App\Filament\Actions\Cheerful\RestoreAction; use App\Filament\Actions\DefaultBulkActions; use App\Filament\Columns\TimestampColumns; +use App\Filament\Resources\Master\Students\Actions\ChangePasswordAction; use App\Models\Student; use Filament\Actions\BulkActionGroup; use Filament\Support\Enums\Width; @@ -92,6 +93,8 @@ public static function configure(Table $table): Table ->visible(fn () => auth()->user()->hasRole(RoleEnum::Developer)), ]) ->recordActions([ + ChangePasswordAction::make('changePassword'), + EditAction::make() ->modalWidth(Width::Large),