Skip to content

Commit

Permalink
Ability to a update users password (#1458)
Browse files Browse the repository at this point in the history
A simple PR which allows you to staff to update a users password if
needed via a customer.

---------

Co-authored-by: Glenn Jacobs <glenn@neondigital.co.uk>
  • Loading branch information
alecritson and glennjacobs authored Jan 8, 2024
1 parent 10c9a82 commit 7f80378
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/admin/resources/lang/en/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,16 @@
'label' => 'Email',
],
],

'form' => [
'email' => [
'label' => 'Email',
],
'password' => [
'label' => 'New Password',
],
'password_confirmation' => [
'label' => 'Confirm New Password',
],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,60 @@

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([
Tables\Columns\TextColumn::make('name')
->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),

]),
]);
}
}

0 comments on commit 7f80378

Please sign in to comment.