|
7 | 7 | use Eclipse\Core\Filament\Resources; |
8 | 8 | use Eclipse\Core\Models\User; |
9 | 9 | use Filament\Forms; |
| 10 | +use Filament\Forms\Components\Actions\Action; |
10 | 11 | use Filament\Forms\Form; |
| 12 | +use Filament\Forms\Set; |
11 | 13 | use Filament\Infolists\Components\Group; |
12 | 14 | use Filament\Infolists\Components\Section; |
13 | 15 | use Filament\Infolists\Components\SpatieMediaLibraryImageEntry; |
|
23 | 25 | use Illuminate\Database\Eloquent\Builder; |
24 | 26 | use Illuminate\Database\Eloquent\SoftDeletingScope; |
25 | 27 | use Illuminate\Support\Facades\Hash; |
| 28 | +use Illuminate\Support\Str; |
26 | 29 | use pxlrbt\FilamentExcel\Actions\Tables\ExportBulkAction; |
27 | 30 | use STS\FilamentImpersonate\Tables\Actions\Impersonate; |
28 | 31 |
|
@@ -56,7 +59,16 @@ public static function form(Form $form): Form |
56 | 59 | ->dehydrateStateUsing(fn ($state) => Hash::make($state)) |
57 | 60 | ->dehydrated(fn ($state) => filled($state)) |
58 | 61 | ->required(fn (string $context): bool => $context === 'create') |
59 | | - ->label(fn (string $context): string => $context === 'create' ? 'Password' : 'Set new password'), |
| 62 | + ->label(fn (string $context): string => $context === 'create' ? 'Password' : 'Set new password') |
| 63 | + ->suffixAction( |
| 64 | + Action::make('randomPassword') |
| 65 | + ->icon('heroicon-s-arrow-path') |
| 66 | + ->tooltip(__('Random password generator')) |
| 67 | + ->color('gray') |
| 68 | + ->action( |
| 69 | + fn (Set $set) => $set('password', Str::password(16)) |
| 70 | + ) |
| 71 | + ), |
60 | 72 | Forms\Components\Select::make('roles') |
61 | 73 | ->relationship('roles', 'name') |
62 | 74 | ->saveRelationshipsUsing(function (User $record, $state) { |
|
0 commit comments