diff --git a/packages/admin/resources/lang/en/user.php b/packages/admin/resources/lang/en/user.php index 0c1c37e0e5..f42af5382c 100644 --- a/packages/admin/resources/lang/en/user.php +++ b/packages/admin/resources/lang/en/user.php @@ -14,4 +14,16 @@ 'label' => 'Email', ], ], + + 'form' => [ + 'email' => [ + 'label' => 'Email', + ], + 'password' => [ + 'label' => 'New Password', + ], + 'password_confirmation' => [ + 'label' => 'Confirm New Password', + ], + ], ]; diff --git a/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/UserRelationManager.php b/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/UserRelationManager.php index e1e5691b76..38fe9e3c92 100644 --- a/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/UserRelationManager.php +++ b/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/UserRelationManager.php @@ -2,14 +2,22 @@ namespace Lunar\Admin\Filament\Resources\CustomerResource\RelationManagers; +use Filament\Forms\Components\Group; +use Filament\Forms\Components\TextInput; use Filament\Resources\RelationManagers\RelationManager; use Filament\Tables; use Filament\Tables\Table; +use Illuminate\Support\Facades\Hash; class UserRelationManager extends RelationManager { protected static string $relationship = 'users'; + public function isReadOnly(): bool + { + return false; + } + public function table(Table $table): Table { return $table->columns([ @@ -17,6 +25,37 @@ public function table(Table $table): Table ->label(__('lunarpanel::user.table.name.label')), Tables\Columns\TextColumn::make('email') ->label(__('lunarpanel::user.table.email.label')), + ])->actions([ + Tables\Actions\EditAction::make('edit') + ->form([ + Group::make([ + TextInput::make('email') + ->label( + __('lunarpanel::user.form.email.label') + ) + ->required() + ->email() + ->columnSpan(2), + TextInput::make('password') + ->label( + __('lunarpanel::user.form.password.label') + ) + ->password() + ->minLength(8) + ->required(fn ($record) => blank($record)) + ->dehydrateStateUsing(fn ($state) => Hash::make($state)) + ->dehydrated(fn (?string $state): bool => filled($state)) + ->currentPassword(false) + ->confirmed(), + TextInput::make('password_confirmation') + ->label( + __('lunarpanel::user.form.password_confirmation.label') + ) + ->password() + ->minLength(8), + ])->columns(2), + + ]), ]); } }